Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.
Hi,
I'm new to DAX and need some help, I'm creating a measure in a tabular cube in SSAS. I need to retreive the LastYearLastWeek data from x column:
LastYearLastWeek:= CALCULATE([x], FILTER(ALL(Time), Time[WeekNumber] = SELECTEDVALUE(Time[WeekNumber]) -1 && Time[Year] = SELECTEDVALUE(Time[Year])-1))
But I get this error in the syntax: comparison operations don't support comparing values type Text with Values of Type Number. Considering using VALUE or FORMAT functions to convert one of the values.
Fields used: WeekNumber and Year from Time table are whole numbers.
It doesn't really make sense to me, any tips on how to fix it?
Also maybe there is a better way to get LastWeekLastYear, do you know of any?
Thanks
Solved! Go to Solution.
Hi @Anonymous ,
Since the error pointed out that it was a data type issue, could you double check the data type of Time[WeekNumber] and Time[Year] columns? Or, if the expression works with "VALUE" function, the data type of the two columns is indeed text.
LastYearLastWeek :=
CALCULATE (
[x],
FILTER (
ALL ( Time ),
Time[WeekNumber]
= VALUE ( SELECTEDVALUE ( Time[WeekNumber] ) ) - 1
&& Time[Year]
= VALUE ( SELECTEDVALUE ( Time[Year] ) ) - 1
)
)
Then, is [x] a column or a measure? If it is a column, it may need to use SUM, MAX, etc, functions with [x].
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Since the error pointed out that it was a data type issue, could you double check the data type of Time[WeekNumber] and Time[Year] columns? Or, if the expression works with "VALUE" function, the data type of the two columns is indeed text.
LastYearLastWeek :=
CALCULATE (
[x],
FILTER (
ALL ( Time ),
Time[WeekNumber]
= VALUE ( SELECTEDVALUE ( Time[WeekNumber] ) ) - 1
&& Time[Year]
= VALUE ( SELECTEDVALUE ( Time[Year] ) ) - 1
)
)
Then, is [x] a column or a measure? If it is a column, it may need to use SUM, MAX, etc, functions with [x].
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the November 2023 Power BI update to learn about new features.
Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.
Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!