Forum Discussion
ApurvaKhatri
8 years agoHelper III
Get value for previous month
Data GroupingPoint GroupingCount GroupingDate EndOfPeriod 50 2017-08-31 EndOfPeriod 45 2017-07-31 EndOfPeriod 49 2017-06-30 EndOfPeriod 54 2017-05-31 EndOfPeriod 58 2017-04-30 EndOfPeriod 5...
- 8 years ago
Hi ApurvaKhatri
Add this calculated column
PreviousMonthCount = VAR Previous_Month = MAXX ( FILTER ( Table1, Table1[GroupingDate] < EARLIER ( Table1[GroupingDate] ) ), Table1[GroupingDate] ) RETURN CALCULATE ( SUM ( Table1[GroupingCount] ), FILTER ( Table1, Table1[GroupingDate] = Previous_Month ) ) - 8 years ago
Hi ApurvaKhatri
Alternatively, you could use a "MEASURE" as well
PreviousMonthCount = VAR Previous_Month = MAXX ( FILTER ( ALL ( Table1 ), Table1[GroupingDate] < VALUES ( Table1[GroupingDate] ) ), Table1[GroupingDate] ) RETURN IF ( HASONEVALUE ( Table1[GroupingDate] ), CALCULATE ( VALUES ( Table1[GroupingCount] ), FILTER ( ALL ( Table1 ), Table1[GroupingDate] = Previous_Month ) ) )
ApurvaKhatri
8 years agoHelper III
Is it possible to have it without the calender table
Anonymous
8 years agoNot applicable
Best practice dictates using a calendar table whenever you're adding time intelligence measures. I STRONGLY recommend reconsidering. The initial effort to build a calendar table will FAR outweigh the needless complexity that your DAX measures will need to make up for the fact that a calendar table is missing.
Please refer to these resources:
https://www.sqlbi.com/articles/time-intelligence-in-power-bi-desktop/
https://powerpivotpro.com/2016/01/year-to-date-in-previousprior-year/
- Zubair_Muhammad8 years agoCommunity Champion
Hi ApurvaKhatri
Add this calculated column
PreviousMonthCount = VAR Previous_Month = MAXX ( FILTER ( Table1, Table1[GroupingDate] < EARLIER ( Table1[GroupingDate] ) ), Table1[GroupingDate] ) RETURN CALCULATE ( SUM ( Table1[GroupingCount] ), FILTER ( Table1, Table1[GroupingDate] = Previous_Month ) )- Zubair_Muhammad8 years agoCommunity Champion
Hi ApurvaKhatri
Alternatively, you could use a "MEASURE" as well
PreviousMonthCount = VAR Previous_Month = MAXX ( FILTER ( ALL ( Table1 ), Table1[GroupingDate] < VALUES ( Table1[GroupingDate] ) ), Table1[GroupingDate] ) RETURN IF ( HASONEVALUE ( Table1[GroupingDate] ), CALCULATE ( VALUES ( Table1[GroupingCount] ), FILTER ( ALL ( Table1 ), Table1[GroupingDate] = Previous_Month ) ) )