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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
msuser48
Helper I
Helper I

Union tables with the same columns, and show them in a Pie Chart

I have 3 different tables. The tables all have the same column, "col1", with different values in them.

 

I need to show the distribution of values in col1 for all 3 tables in a part chart.

 

So lets say there are..

- 25 rows in table 1's col1 with the value "No"

- 25 rows in table 2's col1 with the value "Maybe"

- 50 rows in table 3's col1 with the value "Yes"

 

I need a pie chart to show 3 slices: No, Maybe and Yes with their respective percentages (25%, 25%, 50% in this example case).

 

How to achieve this?

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @msuser48 ,

I created some data:

vyangliumsft_0-1663913991414.png

Here are the steps you can follow:

1. Create a table with Enter data.

vyangliumsft_1-1663913991415.png

2. Create measure.

Measure =
var _all=[Measure1]+ [Measure2] +[Measure3]
return
SWITCH(
    TRUE(),
    MAX('Table'[all])="table1",DIVIDE([Measure1],_all),
    MAX('Table'[all])="table2",DIVIDE([Measure2],_all),
    MAX('Table'[all])="table3",DIVIDE([Measure3],_all)
)

3. Result:

vyangliumsft_2-1663913991421.png

 

Best Regards,

Liu Yang

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

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @msuser48 ,

I created some data:

vyangliumsft_0-1663913991414.png

Here are the steps you can follow:

1. Create a table with Enter data.

vyangliumsft_1-1663913991415.png

2. Create measure.

Measure =
var _all=[Measure1]+ [Measure2] +[Measure3]
return
SWITCH(
    TRUE(),
    MAX('Table'[all])="table1",DIVIDE([Measure1],_all),
    MAX('Table'[all])="table2",DIVIDE([Measure2],_all),
    MAX('Table'[all])="table3",DIVIDE([Measure3],_all)
)

3. Result:

vyangliumsft_2-1663913991421.png

 

Best Regards,

Liu Yang

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

themistoklis
Community Champion
Community Champion

@msuser48 

 

Create a new Table (Menu Bar --> Modelling --> New Table) and add the following formula:

 

NEW_Table = UNION(SUMMARIZE(Table1,'Table1'[col1], "ValueName", "No"),SUMMARIZE(Table2,'Table2'[col1], "ValueName", "Maybe"),SUMMARIZE(Table3,'Table3'[col1], "ValueName", "Yes"))
 
Then add a pie chart visual and put col1 field to Legend section and ValueName field to Values section of the visual
Finally go to 'Format' of the visual --> Detail Labels --> Label Contents (Data Value, percent of Total)
parry2k
Super User
Super User

@msuser48 easier to append tables in power query and then everything will be super easy.

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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