Forum Discussion
Variation from previous period (discontinuous periods)
- 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
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
- Syndicate_Admin5 years agoAdministrator
Thank you very much Xiaoxin for the help!!! It was just what I needed!!!
As a whole I adapted the date in the currDate variable and it worked perfectly. The code looked like this to me:
% Increase ?VAR currDate =MAX ( OCA[Date of Issue] )VAR prevDate =CALCULATE (MAX ( 'Calendar Table'[Date] );FILTER ( ALLSELECTED ('Calendar Table'); 'Calendar table'[Date] < currDate && [MAX price] <> BLANK() );VALUES ( OCA[Article] ))VAR prevAmount =CALCULATE (max(OCA[Unit price without discounts UM purchases]);FILTER ( ALLSELECTED ( 'Calendar Table' ); 'Calendar table'[Date] ? prevDate );VALUES ( OCA[Article] ))RETURNDIVIDE ( max(OCA[Unit price without discounts UM purchases]) - prevAmount; prevAmount )- Anonymous5 years agoNot applicable
Hi flitvak,
I'm glad to hear my formula helps. 😊
If you have any other requirements, you can feel free to post here with detailed information.
Regards,Xiaoxin Sheng