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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Saxon10
Post Prodigy
Post Prodigy

SWITCH ROW TO COLUMN IN POWER BI VISULATION

 

Hi,

 

I changed the data from row to column in Power BI visualization but the country still showing on the Legend. I would like to show the report in Power BI visualization by country with status not status by county.

 

Actual Data:

 

COUNTRYUKUSINDIASASRLPAKBANAFGENG
MATCHED14228581219077282124284406216292179342193704216
NOT MATCHED 56133656372590308684221053729101098
NOT REQUIRED284698       284398
NOT MATCHED 56133656372590308684221053729101098

 

Actual Power BI data report

POWER BI ROW TO COLUMN.PNG

 

Desired Result

SWITCH ROW TO COLUMN.PNG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hello @Saxon10 ,

Depending on your description, you can create a calculated table as follows.

Table_2 - UNION(

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","UK","Value",'Table_1'[UK]),

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","US","Value",'Table_1'[US]),

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","INDIA","Value",'Table_1'[INDIA]),

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","SA","Value",'Table_1'[SA]),

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","SRL","Value",'Table_1'[SRL]),

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","PAK","Value",'Table_1'[PAK]),

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","BAN","Value",'Table_1'[BAN]),

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","AFG","Value",'Table_1'[AFG]),

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","ENG","Value",'Table_1'[ENG])

)


Result:

v-yuaj-msft_0-1607325786100.png

I hope that's what you were looking for.

Best regards

Yuna

If this post helps,then consider Accepting it as the solution to help other members find it faster.

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hello @Saxon10 ,

Depending on your description, you can create a calculated table as follows.

Table_2 - UNION(

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","UK","Value",'Table_1'[UK]),

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","US","Value",'Table_1'[US]),

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","INDIA","Value",'Table_1'[INDIA]),

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","SA","Value",'Table_1'[SA]),

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","SRL","Value",'Table_1'[SRL]),

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","PAK","Value",'Table_1'[PAK]),

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","BAN","Value",'Table_1'[BAN]),

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","AFG","Value",'Table_1'[AFG]),

SELECTCOLUMNS('Table_1',"Status",'Table_1'[COUNTRY],"Country","ENG","Value",'Table_1'[ENG])

)


Result:

v-yuaj-msft_0-1607325786100.png

I hope that's what you were looking for.

Best regards

Yuna

If this post helps,then consider Accepting it as the solution to help other members find it faster.

Thanks for your time. This is exactly I am looking for to achieve my desired result.  

amitchandak
Super User
Super User

@Saxon10 , are UK, US are measures then how orginal data looks like ?

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

The 9 column are came from multiple dataset some of the theme numbers columns and some of the column are text and numbers. it's very large database. 

amitchandak
Super User
Super User

@Saxon10 , Unpivot this data, You will get country and status as columns. ANd value as one more column (numeric

In matrix you can status as row, Country as column and Value in Value .

 

https://radacad.com/pivot-and-unpivot-with-power-bi

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

thanks for quick reply. I can't use unpivot option because the column came from DAX measure not part of the original data. Could you please advise is there any alternative way? 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.