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
Saxon202202
Helper III
Helper III

Matrix table using multiple column

Hi,

I have data data table and the table contain country id, country code and qty.

 

In visualisation, I like to breakdown by country id, country code and qty in matrix table.
At the moment all the country code showing in one column by country id but the expected result is one by one, row by column (country Id by country code). Is that possible to achieve in visuslation?

Example: Return the releevant country code in each columns. If country code - RS in row and column will be show only RS country code.

 

Saxon202202_1-1664836350139.png

 

 

 

Saxon202202_0-1664836320683.png

 

https://www.dropbox.com/s/18q4wdjaszlml3x/PBI%20VISUAL%20-MATRIX.pbix?dl=0

1 ACCEPTED SOLUTION

Hi @Saxon202202 

I've edited the PBIX with a calculated column to rank Country Code by Country ID.

Index = 
RANKX (
    FILTER ( DATA, DATA[COUNTRY ID] = EARLIER ( DATA[COUNTRY ID] ) ),
    DATA[COUNTRY CODE],
    ,
    ASC,
    DENSE
)









Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

10 REPLIES 10
danextian
Super User
Super User

Hi @Saxon202202,

 

If I got your user case right, my approach would be to create an index column for each Country ID, use that as the column header and use SELECTEDVALUE to show the country code in the row. This is the closest I could get to. Please refer to the attached PBIX

danextian_1-1664849060879.png

 

 

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hello, Thanks for your suggestion. The country id is not part of raw data, it's came from DAX code based on the different columns so unable to modify the changes in Power query. Is that any chance can I have the same index output by using DAX code. I can get the same output in Excel by using COUNTIFS =COUNTIFS(A2:A$2,A2) but not sure how can make DAX code to get the same output. 

Hi @Saxon202202 

I've edited the PBIX with a calculated column to rank Country Code by Country ID.

Index = 
RANKX (
    FILTER ( DATA, DATA[COUNTRY ID] = EARLIER ( DATA[COUNTRY ID] ) ),
    DATA[COUNTRY CODE],
    ,
    ASC,
    DENSE
)









Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian 
Thank you so much for your help to make DAX code for Index. The last question is how do you made visual because I am unable to get the same visual output like you made it.
Can you please advise. 
My visual is different compare to yours.

Saxon202202_0-1665007739464.png

 

Hi @Saxon202202 ,

Change the column font color to white so they are not visible (with a white background of course).  Then under Values, turn on Switch values to rows.

danextian_0-1665008978549.png

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian , Thank you so much for your quick respones and help.

Dinesh_Suranga
Continued Contributor
Continued Contributor

@Saxon202202 

Hi,

Could you please let me know your COUNTRY ID and COUNTRY CODE static or dynamic ?

Thank you.

@Dinesh_Suranga, Thanks for your response. Tge both columns are static. 

Anonymous
Not applicable

Hi  ,

This can be resolved using switch function

SWITCH = 

SWITCH(
    TRUE(),
    SELECTEDVALUE(DATA[COUNTRY ID]) = "RS",SELECTEDVALUE(DATA[COUNTRY CODE]),
    SELECTEDVALUE(DATA[COUNTRY ID]) = "PD",SELECTEDVALUE(DATA[COUNTRY CODE]),
    SELECTEDVALUE(DATA[COUNTRY ID]) = "OQ",SUM(DATA[ORDER QTY])
)



Dax_Noob_1-1664845963406.png

 

BR

@Saxon202202

@Anonymous @, Thanks for your reply. The country id should be show the relevant country code.

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.