Forum Discussion
Slope calculation given a date axis
Hi all,
I have a table of sales over time (number as value, date as axis), and I'm attempting to make a calculation that displays the slope for the value, given the start and end points are for whatever criteria is currently selected.
I have an initial and ending value, and % change between the two, but can't figure out how to translate that into slope given a date axis.
2 Replies
- v-yuta-msftCommunity Support
Hi RMDNA,
Which kind of slope you want to achieve? Maybe some custom chart can meet your requirement. In addtion, could you share some sample data for further analysis?
Regards,
Jimmy Tao
- AnonymousNot applicable
I am wondering about this one as well. I have not been able to find a nice "SLOPE" function in the DAX library.
I did find a custome function that works when the x-axis are some kind of number in integrer format. But my x-axis is a month-day/year.
I am looking for any tips or tricks on this one...
This would be a sample of the data set:
dt_RPTMONTH_INC Incoming Incidents
11/1/2016 0:00 9256
12/1/2016 0:00 8350
1/1/2017 0:00 8905
2/1/2017 0:00 8973
3/1/2017 0:00 9864
4/1/2017 0:00 8495
5/1/2017 0:00 9533
6/1/2017 0:00 9227
7/1/2017 0:00 8341
8/1/2017 0:00 9295
9/1/2017 0:00 8923
10/1/2017 0:00 8939
11/1/2017 0:00 8213
12/1/2017 0:00 6902
1/1/2018 0:00 7965
2/1/2018 0:00 8042
3/1/2018 0:00 8906
4/1/2018 0:00 8758
5/1/2018 0:00 8965
6/1/2018 0:00 8382
7/1/2018 0:00 8656
8/1/2018 0:00 8901
9/1/2018 0:00 8101
10/1/2018 0:00 8439
11/1/2018 0:00 2952
Here is the function I'm using but it's not calculating the slope correctly being the Known[X] values are a date.QRC Inc Slope Test =VAR Known =FILTER (SELECTCOLUMNS (DATESINPERIOD(PBI_INCOMING_16_MONTHS[dt_RPTMONTH_INC],LASTDATE (PARALLELPERIOD (PBI_INCOMING_16_MONTHS[dt_RPTMONTH_INC], -1 * [QRC Month Offset], MONTH)),-9,MONTH),"Known[X]", PBI_INCOMING_16_MONTHS[dt_RPTMONTH_INC],"Known[Y]", PBI_INCOMING_16_MONTHS[Incoming Incidents]),AND (NOT ( ISBLANK ( Known[X] ) ),NOT ( ISBLANK ( Known[Y] ) )))VAR Count_Items =COUNTROWS ( Known )VAR Sum_X =SUMX ( Known, Known[X] )VAR Sum_X2 =SUMX ( Known, Known[X] ^ 2 )VAR Sum_Y =SUMX ( Known, Known[Y] )VAR Sum_XY =SUMX ( Known, Known[X] * Known[Y] )VAR Average_X =AVERAGEX ( Known, Known[X] )VAR Average_Y =AVERAGEX ( Known, Known[Y] )VAR Slope =DIVIDE (Count_Items * Sum_XY - Sum_X * Sum_Y,Count_Items * Sum_X2 - Sum_X ^ 2)RETURNSlope