Add predictor to model quantile function in Tableau - forecasting

Does anyone know how to get a model quantile function to project into future using a predictor variable/measure? I have support ticket volume I'm trying to predict using previous months and another measure.
MODEL_QUANTILE(0.5,SUM(Volume),ATTR(DATETRUNC('month',[fiscal date])),SUM(Time / User (min)]))
If I take out the last predictor (Time/User) it produces a smooth curve into future, but only gives me until this month if I have it in. Both measures stop at this month, and I've tried "Infer Properties from Missing Values" and "Extend Date Range"

Related

r function for classifying calendar dates as spring or neap tide

I want to classify each calendar day from 2005-2025 as spring or neap tide. Is there another function or package to do this?
Spring tide also known as king tide is when the tides are most extreme (higher high tides and lower low tides). Spring tide occurs during the full moon and new moon. Neap tide is the less extreme tides encourage during the half moon phases (waxing and waning moon). I am using this website to determine when the lunar cycle is https://www.calendar-12.com/moon_phases/2022#:~:text=Dates%20of%20Moon%20Phases%20in%202022%20Year%20,%2001%3A42%20PM%20%2028%20more%20rows%20. I also tried using the lunar package to figure out when the dates of the lunar phase are, but ran into issues getting this to work, namely I keep getting the error of an invalid trim argument, but I have already coerced the dates to be in a date format, so I'm not sure why that is happening.
The lunar cycle generally changes the moon phases every week, but there is variation. Typically whenever the moon phase would be spring tide, I will assign three days on either side of the date of the full or new moon to be spring tide days. Days assigned to neap tide are three days on either side of the half moon. Sometimes I have to give or take a day for either assignment when the moon phase change is not exactly 7 days.
So far I have only coded each day by hand in excel (physically typed the word spring or neap in a new column in excel beside the calendar date), but I have 20 years of data to do this for and wanted to find a way to automate it in R. That's why I wondered if a package existed.
Thanks for the help.
What I want my data to look like. In the example, May 8 is a half moon, May 16th is a full moon, May 22nd is a half moon, and May 30th is a new moon.
Code I tried.
dates <- format(seq(as.Date("2005-01-01"), as.Date("2025-01-01"), by="days"), format="%m/%d/%Y")
as.vector(dates)
library(lunar)
lunar.phase(dates, name = TRUE)

Comparation Periods in Google Data Studio

I'm creating a in google data studio that has a table behind with data by day.
I need it to be comparable with the month before, but there's a catch that I'm currently stuck!
The period should be something like:
DAY(date)/MONTH(date)-1/YEAR(date)
This allows the comparation between periods with different number of days, example:
Date of analysis: 28/06/2021 - 27/07/2021
Date of comparation: 28/05/2021 - 27/06/2021
When trying to create something like this in DataStudio (with date range controls) none of the options does this, and for what I've explored, there isn't an option to do a formula like the one above.
The closest I get is "Previous Period" but that makes the Date of Comparation 29/05/2021 - 27/06/2021, missing the 28/05/2021.
I'm really stuck and running out of ideas, I've even considered changing the SQL query behind to convert the days somehow.
I've done this by mocking the dates for the comparator.
The other way is to create two series, and don't use the comparator.
Series #1 will have label 28/06/2021 and data from 28/06/2021 (current period).
Series #2 will have label 28/06/2021 (the same) and data from 28/05/2021 (previous period).
They plot nicely:

how to create a Salesforce formula that can calculate the highest figure for last month?

in Salesforce, how to create a formula that calculate the highest figure for last month? for example, if I have an object that keeps records that created in Sept, now would like to calculate its max value (in this case, should be 20 on 3/8/2019) in last month's (August). If it's in July, then need to calculate for June. How to construct the right formula expression? Thanks very much!
Date Value
1/9/2019 10
1/8/2019 14
2/8/2019 15
3/8/2019 20
....
30/8/2019 15
You can't do this with normal formulas on records because they "see" only current records (and some related via lookup), not other rows in same table.
You could make another object called "accounting periods" or something like that. Link all these entries to periods (months) in master-detail relationship. You'll then be able to use rollup summary with MAX(). Still not great because you need lookup to previous month to pull it but should give you an idea.
You could make a report that achieves something like that. PREVGROUPVAL will let you do some amazing & scary stuff. https://trailhead.salesforce.com/en/content/learn/projects/rd-summary-formulas/rd-compare-groups Then... if all you need is a report - great. If you really need it saved somewhere - you could look into reporting snapshots & save results in helper object...
If you want to do it without any data model changes like that master-detail or helper object - you could also write some code. Nightly batch job (running daily? only on 1st day of month?) should be pretty simple.
Without code - in a pinch you could make a Flow that queries records from previous month. Bit expensive to run such thing for August every time you add a September record but if you discarded other options...

How do I calculate the percentage of a count function?

I am trying to take the percentage of a count function so to create a MS BIDS report resembling this excel file:
Excel Close Rate Summary
The unique identifier for the opportunities is the field "opportunityid", so I am using COUNT(Fields!opportunityid.Value) to determine the number of cases in each stage. I want to write an expression that will return the percentage of cases in each stage per creation month. Which can be seen in the above excel screenshot.
This is my current MS BIDS report when i preview it
To be more specific, I want to have the percentage of "Active" and "New" opportunities in January to represent 67% and 33% respectively. 67% comes from 4/6. The 4 comes from the active opportunities out of the 6 opportunities created in January. Likewise, the 33% comes from the 2 new opportunities out of the 6 that were created in January.
There are more stage names than Active and New. Other options include New, Warm, Hot, Implementation, Active, Hibernate or Canceled. This is relevant to mention because I have tried to create an expression that counts based on the number of opportunities with a specific stage name, but have been unsuccessful.
Currently the expression I am using to calculate the percentage is:
=COUNT(Fields!new_rptstage.Value)/SUM(COUNT(Fields!opportunityid.Value),"GroupbyStageName")
Based on this expression, I am only able to get 1/1 or 100% for each of the stage names. I have tried a bunch of variations of the above expression by changing the scope, but have been unsuccessful in getting the desired results. Can someone explain how to correct this?
SAMPLE DATA:
In the sample data, I want the expression to be in the percentage column. The percentage should be the # of cases in a particular stage for the total cases that month. So looking at the above picture:
Active February 54 54/168 [have 54/168 display as a percentage]
Warm February 8 8/168
etc.
EDIT:
These are the expressions that may help show the underlying data in the chart.
The creation month expression is
=Fields!MonthCreated.Value & " " & year(Fields!createdon.Value)
The percent expression is listed above.
You don't want to use the COUNT() function. COUNT(*) returns a count of the number of rows that have a value. It doesn't return the actual value.
Since you've only showed a screen shot of your report, I don't know how your underlying data columns relate to it, but what you want to do for your Percent column expression is this:
This is psuedo code because I don't know your dataset field names:
CaseCount.Value / SUM(CaseCount.Value)
EDIT: Now that I better understand how your data relates to your report, I think the only change you need to make to your existing formula is casting it to a decimal type. It's probably rounding all fractions up to 1.
Try this for the expression in your percentage column:
=CDbl(COUNT(Fields!new_rptstage.Value))/CDbl(SUM(COUNT(Fields!opportunityid.Value),"GroupbyStageName"))

Hide weekends on WPF toolkit chart

I am making a small app that plots financial price data and since the finance markets are closed on the weekends, I have no data for those days. By default the chart, found in the new WPF Toolkit, shows a large gap between Friday and following Monday and this behaviour is not acceptable. I am trying to figure out a way to "hide" the weekend gaps but can't seem to find any good solutions. So far, I figured that I would have to overload the standard DateTime struct (how?) which will be able to recognize and skip weekends and holidays. I am looking for suggestions and/or pointers before I start down that slippery slope.
Some more details:
I am given a wide range of data - currently daily closing prices on NYSE. I am using the DayTimeAxis to plot the independent variable of LineSeries which is of type DateTime. It currently simply plots all the prices, one day at a time - and that's where the devil is, it shows wider gaps due to lack of data for Saturdays and Sundays and some major holidays.
I will eventually have to show more detailed (hourly, minute) chart once data becomes available, but the problem will remain if the user will want to view hourly data for some Friday and the following Monday.
After much playing around with various options, I ended up using the CategoryAxis instead of DateTimeAxis. It treats each day as a category without inferring the relationship between the days.
The data can still be kept as DateTime objects for any necessary calculations and you just have to worry about the ToString (that's what CategoryAxis to label each category). Or just throw them all in as strings - technically calculations are done on the data points, not the array of dates so not much of a loss here...
If you will plot candlestick or ohlc you can't go with toolkit (you can but it will be VERY unpleasant) if you are open to use component use visifire's the one you may go. if you can't figure it out with that send a sample code please.
Completely off the top of my head, so I'm not sure how feasible this would be, but could you possibly set up a value converter on the Width property of the data point that would return "Auto" on a weekday and 0 for a weekend?

Resources