Forum Discussion
DoD Variation column using Dateaddd on Business Days
- Anonymous9 years ago
Hi pitucc,
My formula is a measure, if you direct use it as calculate column ,it may caused the issue.
In addition, if you need you can also use below formula: (calculate column version)
DoD diff = VAR previous_date = MAXX ( FILTER ( ALL ( 'Sample' ), [Date] < EARLIER ( [Date] ) ), [Date] ) RETURN IF ( previous_date <> 0, AVERAGEX ( FILTER ( ALL ( 'Sample' ), [Product] = EARLIER ( [Product] ) && [Date] = EARLIER ( [Date] ) ), [Price] ) - AVERAGEX ( FILTER ( ALL ( 'Sample' ), [Product] = EARLIER ( [Product] ) && [Date] = previous_date ), [Price] ), 0 )Regards,
Xiaoxin Sheng
- 9 years ago
Hello,
I just wnated to close the topic, to compute a variation for anything alse than day on day, in the computation of "previous_avg" just replace "current_date" by " (current_date-XX) where XX is the lag you want for your variation.
For a WoW variation I have used the code below :
WoW Cheap = VAR current_Product =LASTNONBLANK ( DataBase[Name]; [Name] ) VAR current_date = MAX ( DataBase[ValuationDate] ) VAR current_avg = AVERAGEX ( FILTER ( ALL ( DataBase ); [Name] = current_Product && [ValuationDate] = current_date ); [Cheap] ) VAR previous_avg = AVERAGEX ( FILTER ( ALL ( DataBase ); [Name] = current_Product && [ValuationDate] = MAXX ( FILTER ( ALL ( DataBase ); [Name] = current_Product && [ValuationDate] < (current_date-6) ); [ValuationDate] ) ); [Cheap] ) RETURN IF ( previous_avg <> 0; current_avg - previous_avg; 0 )Many thanks once again for your help !
Hello,
Thanks for your help but I have litterally copy pasted your formula but it don't have the same result as you do...
Any idea why ?
Furthermore, is the formula easely adaptable to compte a Month on month variation difference ?
Thanks
Hi pitucc,
My formula is a measure, if you direct use it as calculate column ,it may caused the issue.
In addition, if you need you can also use below formula: (calculate column version)
DoD diff =
VAR previous_date =
MAXX ( FILTER ( ALL ( 'Sample' ), [Date] < EARLIER ( [Date] ) ), [Date] )
RETURN
IF (
previous_date <> 0,
AVERAGEX (
FILTER (
ALL ( 'Sample' ),
[Product] = EARLIER ( [Product] )
&& [Date] = EARLIER ( [Date] )
),
[Price]
)
- AVERAGEX (
FILTER (
ALL ( 'Sample' ),
[Product] = EARLIER ( [Product] )
&& [Date] = previous_date
),
[Price]
),
0
)
Regards,
Xiaoxin Sheng
- pitucc9 years agoHelper I
That's perfect many thanks !
Is it easely adaptable for MoM variation or 21days on 21 days variation ?
Oh and one last question, what is difference between using your solution as column formula or as a measure ?
Thanks
- pitucc9 years agoHelper I
Hello,
I just wnated to close the topic, to compute a variation for anything alse than day on day, in the computation of "previous_avg" just replace "current_date" by " (current_date-XX) where XX is the lag you want for your variation.
For a WoW variation I have used the code below :
WoW Cheap = VAR current_Product =LASTNONBLANK ( DataBase[Name]; [Name] ) VAR current_date = MAX ( DataBase[ValuationDate] ) VAR current_avg = AVERAGEX ( FILTER ( ALL ( DataBase ); [Name] = current_Product && [ValuationDate] = current_date ); [Cheap] ) VAR previous_avg = AVERAGEX ( FILTER ( ALL ( DataBase ); [Name] = current_Product && [ValuationDate] = MAXX ( FILTER ( ALL ( DataBase ); [Name] = current_Product && [ValuationDate] < (current_date-6) ); [ValuationDate] ) ); [Cheap] ) RETURN IF ( previous_avg <> 0; current_avg - previous_avg; 0 )Many thanks once again for your help !