Forum Discussion
Anonymous
6 years agoNot applicable
compare current month vs Previous month
Hi guys, i am new to power bi and i want to compare current month sales with last month. i am having data from 2017 january to 2019 november. i used a dax function for calculating last month ...
tex628
Community Champion
6 years agoThe easiest way to do this is to create a numeric index for your combination of year and month:
| Date | Y/M | Index |
| 2019-01-01 | jan-19 | 1 |
| 2019-02-02 | feb-19 | 2 |
| 2019-02-03 | feb-19 | 2 |
| 2019-03-01 | mar-19 | 3 |
| 2019-04-04 | apr-19 | 4 |
Then reference the previous index in the calculation.
Assuming that the current date is 2019-04, the following will return the index "4":
Previous month =
Calulate(
SELECTEDVALUE( Calendar[Index] );
Calendar[Date] = TODAY()
)
Then you can simply use that to calculate the previous index:
Last_month =
CALCULATE(
SUM(Table1[TotalAmount]);
Calendar[Index] = [Previous month] -1
)
Anonymous
6 years agoNot applicable