Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
RMDNA
Solution Sage
Solution Sage

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 2
v-yuta-msft
Community Support
Community 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

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
)
RETURN
Slope

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.