Reply
francisthe63
Helper I
Helper I
Partially syndicated - Outbound

Use many columns in Power BI as X axis

Hello, I have a table like this 

 

Key A B 

1    Fail OK

2    OK NA

 

I want to have a barchart with A and B in x axis (so 2 bars), and the distribution of Fail, OK and NA as value (Fail, OK, NA as legend), y axis = Number of key 

 

Do you know how to do this ? I want to use only DAX measure, not calculated table 

Maybe calculated column if possible 

But don't want to make unpivot with Query, i don't want to change my table

 

Thank you in advance

1 ACCEPTED SOLUTION

You can simulate unpivoting with DAX by using SELECTCOLUMNS and UNION. For more details, you can check this explanation (https://community.fabric.microsoft.com/t5/Desktop/Unpivot-columns-using-dax/td-p/1350856).

However, I recommend using Power Query instead. I don't see any reason not to use it, but if you have specific reasons for avoiding it, please let me know.

By the way, I don't think you can achieve this without using a calculated table.

View solution in original post

3 REPLIES 3
Gabry
Super User
Super User

Hello,

I think you need to unpivot your A and B columns, like this:

 

KeyTypeValue
1AFail
1BOK
2AOK
2BNA
5AFail
5BOK

 

 

 

Then you just need to put those in the bar chart

 

Gabry_0-1716296194550.png

 

if key is a number like this:

 

Gabry_1-1716296327026.png

 

 

 

Please if it solved your issue mark as accepted solution

 

Yeah but how with DAX ? i want to avoid Power query 

You can simulate unpivoting with DAX by using SELECTCOLUMNS and UNION. For more details, you can check this explanation (https://community.fabric.microsoft.com/t5/Desktop/Unpivot-columns-using-dax/td-p/1350856).

However, I recommend using Power Query instead. I don't see any reason not to use it, but if you have specific reasons for avoiding it, please let me know.

By the way, I don't think you can achieve this without using a calculated table.

avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)