Forum Discussion
PowerBITestingG
4 years agoResolver I
Dynamic Variable in Measure
Hi all, I have the following dax measure = Spend YTD classic =
VAR octoberstart1 = SWITCH(TRUE(),
[MaxOctoberStart]=10/03/2022,"10-03",
[MaxOctoberStart]=10/04/2021,"10-04","10-03")
return...
vojtechsima
4 years agoSuper User
Hi, PowerBITestingG
I think here is the problem:
VAR octoberstart1 = SWITCH(TRUE(),
[MaxOctoberStart]=10/03/2022,"10-03",
[MaxOctoberStart]=10/04/2021,"10-04","10-03")
The 10/03/2022 is probably not recognizable because it's not either string or number, so you have to wrap it with "" to make it a string and then make sure, that MaxOctoberStart returns a date in same format.
Or you can check against DATE function and fill it like this:
VAR octoberstart1 = SWITCH(TRUE(),
[MaxOctoberStart]=DATE(2022,3,10),"10-03",
[MaxOctoberStart]=DATE(2021,4,10),"10-04",
"10-03")- PowerBITestingG4 years agoResolver I
Sadly it seems you cant use dynamic variables in ytd functions. Everything is so contrived in dax
- vojtechsima4 years agoSuper User
PowerBITestingG
Can you share a copyable dataset in text form?
Just a sample that I Can test my analyses.