Forum Discussion

Saxon10's avatar
Saxon10
Icon for Post Prodigy rankPost Prodigy
5 years ago
Solved

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

 

Desired Result

  • Anonymous's avatar
    Anonymous
    5 years ago

    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.

6 Replies

    • Saxon10's avatar
      Saxon10
      Icon for Post Prodigy rankPost Prodigy

      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? 

    • Saxon10's avatar
      Saxon10
      Icon for Post Prodigy rankPost Prodigy

      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. 

  • Anonymous's avatar
    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.

    • Saxon10's avatar
      Saxon10
      Icon for Post Prodigy rankPost Prodigy

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