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
Anonymous
Not applicable

Dax percentage

Hi all,

 

I hope you are doing well.

I am newbie in dax query and I need your help to calculate a percentage measure.

 

I have a table like that:

VariableCountry Measure
B4B5B6France10
B4B5B6USA20
B4France2
B4USA5
B3France1
B3USA2

 

 

So I want to have this report: 

VariableCountry Measure%Measure
B4B5B6France10100%
B4B5B6USA20100%
B4France220%
B4USA525%
B3France440%
B3USA210%

 

The [%Measure] = Measure / Measure for Variable B4B5B6.

The measure for the variable 'B4B5B6' is the denominator for the ratio [%Measure] 

 

VariableCountry Measure%Measure calculation
B4B5B6France10100%->10/10
B4B5B6USA20100%->20/20
B4France220%->2/10
B4USA525%->5/20
B3France440%->4/10
B3USA210%->2/20

 

 

Thank you for your help

 

 

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

1. Insert an index column in power query.

Capture.PNG

2. To create a mueasure as below.

 

Per = 
VAR a =
    MAX ( 'Table'[Country ] )
RETURN
    DIVIDE (
        [measure],
        CALCULATE (
            [measure],
            FILTER ( ALL ( 'Table' ), 'Table'[Index] <= 2 && 'Table'[Country ] = a )
        )
    )

2.PNG

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

1. Insert an index column in power query.

Capture.PNG

2. To create a mueasure as below.

 

Per = 
VAR a =
    MAX ( 'Table'[Country ] )
RETURN
    DIVIDE (
        [measure],
        CALCULATE (
            [measure],
            FILTER ( ALL ( 'Table' ), 'Table'[Index] <= 2 && 'Table'[Country ] = a )
        )
    )

2.PNG

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

@Anonymous 

In the query editor, you can duplicate your Country column by right clicking the column header, then select the entire new column and right click and select "Replace Values..." Assign the variables to the numbers you want. It seems like for the Country France, you divide by 10 and for the Country USA, you divide by 20. So replace "France" with "10" and "USA" with "20." Make sure this column is formatted as a number (decimal number, whole number, etc.). Then you can simply create a column that divides your "Measure" row by your new row which should give you % Measure column. You can format this column as a percentage in the query editor or outside in the "Modeling" tab after selecting your new column in the Fields tab.

Hope this helps!

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.