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
me1982
Frequent Visitor

Adding a MISSING value to a pie chart

In powerBI I have a table of elements and a table of properties (key and value for each propery) . Properties are linked to elements using an element ID.
Not all elements have all the properties.
Sample data:
Elements Table
Element-IDElement-Name
1First element
2Second Element
Properties Table:
Property KeyProperty ValueElement-ID
ColorRed1
ColorBlue2
SizeSmall1
 
I want to show a pie chart with a specific property (For instance shirt size) and its values and for elements that don't have that property I want to see the value Missing or blank.
My current naive solution shows only elements that have that property linked to them.
In the example above the pie chart will have only one 360 degrees slice of the size small when what I want to see are two slices (180 degrees each) one with the size small and the other with the size Missing.
 
I also tried using a measure to retrieve the first property value or Missing if no value found. The problem is I can't use the measure as a pie chart legend.
1 ACCEPTED SOLUTION
v-kongfanf-msft
Community Support
Community Support

Hi @me1982 ,

 

As you said, measure cannot be applied to pie charts. try the following calculated column.

result_ =
VAR elementID = Elements[ElementID]
VAR shirtSize =
    CALCULATE (
        MAX ( 'Properties'[Value] ),
        'Properties'[Key] = "Shirt Size"
            && 'Properties'[ElementID] = elementID
    )
RETURN
    IF ( ISBLANK ( shirtSize ), "Missing", shirtSize )

vkongfanfmsft_0-1709023884094.png

vkongfanfmsft_1-1709023907279.png

 

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

View solution in original post

4 REPLIES 4
v-kongfanf-msft
Community Support
Community Support

Hi @me1982 ,

 

As you said, measure cannot be applied to pie charts. try the following calculated column.

result_ =
VAR elementID = Elements[ElementID]
VAR shirtSize =
    CALCULATE (
        MAX ( 'Properties'[Value] ),
        'Properties'[Key] = "Shirt Size"
            && 'Properties'[ElementID] = elementID
    )
RETURN
    IF ( ISBLANK ( shirtSize ), "Missing", shirtSize )

vkongfanfmsft_0-1709023884094.png

vkongfanfmsft_1-1709023907279.png

 

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Thank you.

This seems to give the correct result. However it does require to add a column for each propery key.

Isn't there a simpler way?

Hi @me1982 ,

 

For now, probably creating a calculated column is the best way to go.

 

Best Regards,
Adamk Kong

gmsamborn
Super User
Super User

I would like to help but I'm a little unclear about your requirements.

 

Can you show the following?

 

1)  Please provide sample data that covers your issue or question completely.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...

 

2) Please show the expected outcome based on the sample data you provided.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

 

3) Please explain how you would expect to get from step 1 to 2.

 

4) If possible, please show your past attempts at a solution.

 

I hope this helps.

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.