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

Calculate row total percentage

I want to calculate Row percentage of product on row basis.

for example, I have dimCountry, dimProduct and FactTable, I put them in matrix visual as show below

timEalll_0-1664522753653.png

 

What i want to achieve is percentage of country per product on row basis as shown below

timEalll_1-1664522935170.png

How can I achieve this using dax

 

1 ACCEPTED SOLUTION
Thejeswar
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

The DAX might change based on the FactTable Structure. But assuming the below is the FactTable structure, I have given the DAX

Thejeswar_1-1664524660351.png

 

You can use the below DAX for this

Product% = 
VAR Numerator = CALCULATE(SUM(FactTable[Numbers]), REMOVEFILTERS(dimCountry[Country]), VALUES(dimCountry[Country]))
VAR Denominator = CALCULATE(SUM(FactTable[Numbers]), REMOVEFILTERS(dimProduct[Product]))
RETURN
DIVIDE(Numerator, Denominator)

 

Set the format of the Product% to Percentage

Thejeswar_0-1664524458761.png

 

If you share the table structure may be that could help!!

 

Regards,

View solution in original post

2 REPLIES 2
Thejeswar
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

The DAX might change based on the FactTable Structure. But assuming the below is the FactTable structure, I have given the DAX

Thejeswar_1-1664524660351.png

 

You can use the below DAX for this

Product% = 
VAR Numerator = CALCULATE(SUM(FactTable[Numbers]), REMOVEFILTERS(dimCountry[Country]), VALUES(dimCountry[Country]))
VAR Denominator = CALCULATE(SUM(FactTable[Numbers]), REMOVEFILTERS(dimProduct[Product]))
RETURN
DIVIDE(Numerator, Denominator)

 

Set the format of the Product% to Percentage

Thejeswar_0-1664524458761.png

 

If you share the table structure may be that could help!!

 

Regards,

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

Jihwan_Kim_1-1664523552495.png

 

 

 

Jihwan_Kim_0-1664523531752.png

 

Percentage measure: =
VAR _bycountry =
    CALCULATE ( [Count measure:], ALLEXCEPT ( 'Fact', Country[Country] ) )
RETURN
    IF ( HASONEVALUE ( Country[Country] ), DIVIDE ( [Count measure:], _bycountry ) )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


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.