March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
I am working in Tabular Editor 3, and trying to create a measure in DAX which will allow me to show data in a calculation group where according to the Year selected in a filter the table will show data for that year and the previous year, dynamically changing as the filter selection changes. I have a working measure for the current year, but am unable to work out why it doesn't work when I try to use "Year - 1" within the calculation.
I have a measure which works to identify the Year selected in the filter:
YearOfEntrySelected = SELECTEDVALUE(LookupEntryYear[YearOfEntry])
The measure I am using works as long as I don't use - 1:
VAR YearSelected = [YearOfEntrySelected]
RETURN
IF(
SELECTEDVALUE( DataCourseApplications[LatestYearOfEntry] ) = YearSelected,
CALCULATE(
COUNTROWS( DataCourseApplications )
, DataCourseApplications[LatestRecord] <> BLANK()
)
)
But does not work when I add the - 1 to the variable (or directly to the Measure and reference that in the IF statement):
VAR YearSelected = [YearOfEntrySelected] - 1
RETURN
IF(
SELECTEDVALUE( DataCourseApplications[LatestYearOfEntry] ) = YearSelected,
CALCULATE(
COUNTROWS( DataCourseApplications )
, DataCourseApplications[LatestRecord] <> BLANK()
)
)
The Year values all look to be formatted as Whole Numbers, so I don't believe that there should be any issue with the minus 1 and it matching to the LatestYearOfEntry.
Any thoughts and ideas welcome - I've asked a number of colleagues and we are all perplexed!
Solved! Go to Solution.
Hi @Anonymous ,
Please have a try.
To avoid this problem, you can use the MAX or MIN function instead of SELECTEDVALUE, which will return the maximum or minimum value in the filter context. For example, you can use this formula:
VAR YearSelected = MAX(LookupEntryYear[YearOfEntry]) - 1
RETURN
IF(
MAX(DataCourseApplications[LatestYearOfEntry]) = YearSelected,
CALCULATE(
COUNTROWS(DataCourseApplications),
DataCourseApplications[LatestRecord] <> BLANK()
)
)
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ Rongtie
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Please have a try.
To avoid this problem, you can use the MAX or MIN function instead of SELECTEDVALUE, which will return the maximum or minimum value in the filter context. For example, you can use this formula:
VAR YearSelected = MAX(LookupEntryYear[YearOfEntry]) - 1
RETURN
IF(
MAX(DataCourseApplications[LatestYearOfEntry]) = YearSelected,
CALCULATE(
COUNTROWS(DataCourseApplications),
DataCourseApplications[LatestRecord] <> BLANK()
)
)
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ Rongtie
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
What's the relevance of calculation groups here? Isn't that something a regular measure can do?
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
111 | |
77 | |
54 | |
53 | |
44 |
User | Count |
---|---|
183 | |
119 | |
77 | |
65 | |
56 |