Forum Discussion
Syndicate_Admin
Administrator
5 years agoVariation from previous period (discontinuous periods)
Good afternoon, the company where I work I need to make a report with the percentage variation in raw materials over the last three years. The downside is that raw materials don't go up every month ...
- Anonymous5 years ago
HI flitvak,
I think you may need to use Dax function to find out the last date that existed valid value in your table, then you can use this with the current category value to lookup corresponding value to compare with current and previous values.
measure = VAR currDate = MAX ( Table[Date] ) VAR prevDate = CALCULATE ( MAX ( Table[Date] ), FILTER ( ALLSELECTED ( Table ), [Date] < currDate && [Amount] <> BLANK () ), VALUES ( Table[Category] ) ) VAR prevAmount = CALCULATE ( SUM ( Table[Amount] ), FILTER ( ALLSELECTED ( Table ), [Date] = prevDate ), VALUES ( Table[Category] ) ) RETURN DIVIDE ( SUM ( Table[Amount] ) - prevAmount, prevAmount )Regards,
Xiaoxin Sheng
Anonymous
5 years agoNot applicable
HI flitvak,
I think you may need to use Dax function to find out the last date that existed valid value in your table, then you can use this with the current category value to lookup corresponding value to compare with current and previous values.
measure =
VAR currDate =
MAX ( Table[Date] )
VAR prevDate =
CALCULATE (
MAX ( Table[Date] ),
FILTER ( ALLSELECTED ( Table ), [Date] < currDate && [Amount] <> BLANK () ),
VALUES ( Table[Category] )
)
VAR prevAmount =
CALCULATE (
SUM ( Table[Amount] ),
FILTER ( ALLSELECTED ( Table ), [Date] = prevDate ),
VALUES ( Table[Category] )
)
RETURN
DIVIDE ( SUM ( Table[Amount] ) - prevAmount, prevAmount )
Regards,
Xiaoxin Sheng