Forum Discussion
Dateadd does not work in DAX in variable
- 3 years ago
You have to pass a measure that select a different measure different by case (not a variable).
Something like this:
MEASURE SWITCH = IF(x > 1, Measure1, Measure2)
MEASURE = CALCULATE(MEASURE SWITCH, DATEADD('Daily KPI'[ga_date],-7,DAY))
So the MEASURE will return the calculate of the measure switch that it will be Measure1 or Measure2.
I hope i'll be helpful
mark as a solution if you resolve
Ciao!
Thanks a lot for the explanation.
So what I should put in the 2nd formula (with the variables) to make it work ? I still wish to keep the dateadd in the final variable
Thank you again
You have to do the calculate in the variable.
And then return the variable.
var sales = CALCULATE(sum('Daily KPI'[sales]),DATEADD('Daily KPI'[date],-7,DAY))
RETURN sales
Enjoy
mark as a solution if you resolve
- bastienmol3 years agoFrequent Visitor
and is there a way to pass a measure, instead of a result ?
in a way that I can keep return CALCULATE(me,DATEADD('Daily KPI'[ga_date],-7,DAY))
The reason for this is in reality my formula in more complexe and I call the sales metrics more than once. So the idea was to push it into a variable, then call the variable.thank you again- lucadelicio3 years ago
Impactful Individual
You have to pass a measure that select a different measure different by case (not a variable).
Something like this:
MEASURE SWITCH = IF(x > 1, Measure1, Measure2)
MEASURE = CALCULATE(MEASURE SWITCH, DATEADD('Daily KPI'[ga_date],-7,DAY))
So the MEASURE will return the calculate of the measure switch that it will be Measure1 or Measure2.
I hope i'll be helpful
mark as a solution if you resolve
Ciao!- bastienmol3 years agoFrequent Visitor
appreciate the time spent - thanks again