Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I have a few switch measures in order to toggle between various time frame calcs for customer sales (MTD, YTD and MAT). They seem to calculate correctly, but if I try to sort by the Sales value measure, the Discount % calculations dissapear. Any ideas why this might be or how to get around it? User will want/need to sort by both columns . Thanks.
Solved! Go to Solution.
Hi @AndySmith,
I think your issue is based on your data model. Could you share a sample file with us and hsow us a screenshot with the result you want. This will make it easier for us to find the solution.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks again! Sadly still no luck. There are definitley times when there are no discounts but that shouldnt matter for the measure. Everything calculates perfectly well then the disc % just disappears when i try to sort
Hi @AndySmith,
I think your issue is based on your data model. Could you share a sample file with us and hsow us a screenshot with the result you want. This will make it easier for us to find the solution.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks Rico
I think it may be the model. Is tabular model but there are blank rows when i bring in every dimension such as customer or product etc. Will consult with the IT team.
Thanks for the reply. I get an error message saying that COALESCE is not a function and cannot be found? I am using a tabular model. Is that likely to make a difference?
Hi @AndySmith -The COALESCE function was introduced in more recent versions of Power BI and SSAS (post-SQL Server 2016).
COALESCE not being recognized in your tabular model is likely because COALESCE is not supported in DAX within earlier versions of SQL Server Analysis Services (SSAS) Tabular Models.
you can try with iferror
Switch - Customer TimeFrame - Discount % =
VAR SelectedFrame = SELECTEDVALUE('Slicer - TimeFrame'[Select Time Frame], "MTD")
VAR DiscountResult =
SWITCH(
TRUE(),
SelectedFrame = "MTD", IFERROR([VE - Discount % MTD], 0),
SelectedFrame = "YTD", IFERROR([VE - Discount % FYTD], 0),
SelectedFrame = "MAT", IFERROR([VE - Discount % MAT], 0),
SelectedFrame = "Date Range", IFERROR([VE - Discount %], 0),
0
)
RETURN DiscountResult
or if isblank() function too
Switch - Customer TimeFrame - Discount % =
VAR SelectedFrame = SELECTEDVALUE('Slicer - TimeFrame'[Select Time Frame], "MTD")
VAR DiscountResult =
SWITCH(
TRUE(),
SelectedFrame = "MTD", IF(ISBLANK([VE - Discount % MTD]), 0, [VE - Discount % MTD]),
SelectedFrame = "YTD", IF(ISBLANK([VE - Discount % FYTD]), 0, [VE - Discount % FYTD]),
SelectedFrame = "MAT", IF(ISBLANK([VE - Discount % MAT]), 0, [VE - Discount % MAT]),
SelectedFrame = "Date Range", IF(ISBLANK([VE - Discount %]), 0, [VE - Discount %]),
0
)
RETURN DiscountResult
Proud to be a Super User! | |
Hi @AndySmith - please find the modified measure for %
Switch - Customer TimeFrame - Discount % =
VAR SelectedFrame = SELECTEDVALUE('Slicer - TimeFrame'[Select Time Frame], "MTD")
VAR DiscountResult =
SWITCH(
TRUE(),
SelectedFrame = "MTD", CALCULATE([VE - Discount % MTD]),
SelectedFrame = "YTD", CALCULATE([VE - Discount % FYTD]),
SelectedFrame = "MAT", CALCULATE([VE - Discount % MAT]),
SelectedFrame = "Date Range", CALCULATE([VE - Discount %]),
0
)
RETURN DiscountResult
common cause for disappearing values when sorting is the presence of blank values in the measure.
Switch - Customer TimeFrame - Discount % =
VAR SelectedFrame = SELECTEDVALUE('Slicer - TimeFrame'[Select Time Frame], "MTD")
VAR DiscountResult =
SWITCH(
TRUE(),
SelectedFrame = "MTD", COALESCE([VE - Discount % MTD], 0),
SelectedFrame = "YTD", COALESCE([VE - Discount % FYTD], 0),
SelectedFrame = "MAT", COALESCE([VE - Discount % MAT], 0),
SelectedFrame = "Date Range", COALESCE([VE - Discount %], 0),
0
)
RETURN DiscountResult
check with the above measure, hope it works in your scenerio
Proud to be a Super User! | |
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!