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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
arsalaan
Frequent Visitor

How to create a matrix with one table column as matrix row and column header?

I am trying to compare conversion rates when exchanging from one country to another. I have column Country as the rows and columns of my Matrix as shown below, and I am trying to populate it with a measure which is the percentage difference in coversion accross countries. 

arsalaan_1-1673341873915.png

 

arsalaan_0-1673341753636.png

My measure = 

=
var index1 = LOOKUPVALUE(LOCATION_ADJUSTMENT_CON[Index],LOCATION_ADJUSTMENT_CON[Country],SELECTEDVALUE(LOCATION_ADJUSTMENT_CON[Country]))
var index2 = LOOKUPVALUE(LOCATION_ADJUSTMENT_CON[Index],LOCATION_ADJUSTMENT_CON[Country], SELECTEDVALUE(LOCATION_ADJUSTMENT_CON[Country]))
return
index1/index2

The above does not work, what am I doing wrong. My desired output is as shown below:
arsalaan_2-1673342002123.png

 



1 ACCEPTED SOLUTION

HI @arsalaan,

You can try to modify the allselected to all to ignore the filter effects:

measure formula =
VAR currCountry =
    VALUES ( LOCATION_ADJUSTMENT_CON[Country] )
VAR newCountry =
    VALUES ( NewTable[Country] )
VAR value1 =
    CALCULATE (
        SUM ( LOCATION_ADJUSTMENT_CON[Index] ),
        FILTER (
            ALL ( LOCATION_ADJUSTMENT_CON ),
            LOCATION_ADJUSTMENT_CON[Country] IN currCountry
        )
    )
VAR value2 =
    CALCULATE (
        SUM ( LOCATION_ADJUSTMENT_CON[Index] ),
        FILTER (
            ALL ( LOCATION_ADJUSTMENT_CON ),
            LOCATION_ADJUSTMENT_CON[Country] IN newCountry
        )
    )
RETURN
    value1 / value2

If these also don't help, can you please share a pbix or some dummy data that keep the raw data structure? They wil help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

HI @arsalaan,

AFIAK, current power bi does not support to get different values from the same source table field at the same time.

In my opinion, I'd like to suggest you create a new unconnected table with all country values, then you can use this field with raw table country as row and column to design the matrix.

NewTable =
DISTINCT ( ALL ( LOCATION_ADJUSTMENT_CON[Country] ) )

measure formula =
VAR currCountry =
    VALUES ( LOCATION_ADJUSTMENT_CON[Country] )
VAR newCountry =
    VALUES ( NewTable[Country] )
VAR value1 =
    CALCULATE (
        SUM ( LOCATION_ADJUSTMENT_CON[Index] ),
        FILTER (
            ALLSELECTED ( LOCATION_ADJUSTMENT_CON ),
            LOCATION_ADJUSTMENT_CON[Country] IN currCountry
        )
    )
VAR value2 =
    CALCULATE (
        SUM ( LOCATION_ADJUSTMENT_CON[Index] ),
        FILTER (
            ALLSELECTED ( LOCATION_ADJUSTMENT_CON ),
            LOCATION_ADJUSTMENT_CON[Country] IN newCountry
        )
    )
RETURN
    value1 / value2

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hey, do you think you can help me out? Really frustrating problem

HI @arsalaan,

You can try to modify the allselected to all to ignore the filter effects:

measure formula =
VAR currCountry =
    VALUES ( LOCATION_ADJUSTMENT_CON[Country] )
VAR newCountry =
    VALUES ( NewTable[Country] )
VAR value1 =
    CALCULATE (
        SUM ( LOCATION_ADJUSTMENT_CON[Index] ),
        FILTER (
            ALL ( LOCATION_ADJUSTMENT_CON ),
            LOCATION_ADJUSTMENT_CON[Country] IN currCountry
        )
    )
VAR value2 =
    CALCULATE (
        SUM ( LOCATION_ADJUSTMENT_CON[Index] ),
        FILTER (
            ALL ( LOCATION_ADJUSTMENT_CON ),
            LOCATION_ADJUSTMENT_CON[Country] IN newCountry
        )
    )
RETURN
    value1 / value2

If these also don't help, can you please share a pbix or some dummy data that keep the raw data structure? They wil help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Tried this way too, does not work 

arsalaan_0-1673419101375.png

 

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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