Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Measure works in table but not chart

I've got a table with multiple different data types. The table looks like this:

stat_typeNameValue
DecimalZXC1.5
DecimalQWE5.6
PercentageTYU0.80


And DAX code like this:

Switch_value =

VAR stat_type = SELECTEDVALUE(data[stat_type])

VAR p = FIND ("Percent", stat_type, 1, 2) // in my case not all values are as clear but a percent but it starts with that.

VAR _d = SELECTEDVALUE(CIA[value])

return

IF(p == 1, FORMAT(SUM(CIA[Percentage_of_value]), "Percent" ), FORMAT(_d, "Fixed"))


I can see from a card on the page it correctly works out the stat type, then the correct part of the if statement is found. When using a table it works fine. But whenever I use any type of graph, its blank. Anyone know why / how to fix it?

 

1 REPLY 1
johnt75
Super User
Super User

FORMAT returns a string, so the value passed in to the graph would not be numeric. You could either have seperate measures which perform calculations on the different types, or you could look at creating a calculation group and use format string expression on the calculation item. You can use DAX inside the format string expression so you can return different format strings depending on logic.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors