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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
JRVianna
New Member

Adequate Percentile of share on a matrix

Hi, I need to fix this code DAX to exibit the last image below:

 

% Share vendas brutas Agrupável =
VAR AllVendasBrutas =
CALCULATE ( [Vendas Brutas], ALL ( dLocalidades ) )
RETURN
DIVIDE ( [Vendas Brutas], AllVendasBrutas )

 

Before:

 

share_antes.PNG

 

 

I need the measure to show the share like this image bellow

 

share_depois.PNG

The share for continent is working, but I need that the share for category shows values that sum is 100%

 

Any doubts, reply this post. Thanks

1 ACCEPTED SOLUTION
123abc
Community Champion
Community Champion

To achieve this, you can use a different approach for calculating the % Share vendas brutas Agrupável for categories. You want the sum of this measure to be 100% for each category. Here's a modified version of your DAX code:

 

% Share vendas brutas Agrupável =
VAR AllVendasBrutas =
CALCULATE([Vendas Brutas], ALL(dLocalidades))

VAR TotalSalesByCategory =
CALCULATE([Vendas Brutas], ALLEXCEPT('YourTable', 'YourTable'[Category]))

RETURN
DIVIDE([Vendas Brutas], IF(ISFILTERED('YourTable'[Category]), TotalSalesByCategory, AllVendasBrutas))

View solution in original post

2 REPLIES 2
123abc
Community Champion
Community Champion

To achieve this, you can use a different approach for calculating the % Share vendas brutas Agrupável for categories. You want the sum of this measure to be 100% for each category. Here's a modified version of your DAX code:

 

% Share vendas brutas Agrupável =
VAR AllVendasBrutas =
CALCULATE([Vendas Brutas], ALL(dLocalidades))

VAR TotalSalesByCategory =
CALCULATE([Vendas Brutas], ALLEXCEPT('YourTable', 'YourTable'[Category]))

RETURN
DIVIDE([Vendas Brutas], IF(ISFILTERED('YourTable'[Category]), TotalSalesByCategory, AllVendasBrutas))

It didn't work, but with a slightly change it works

 

% Share vendas brutas Agrupável =
VAR ShareContinente =
CALCULATE([Vendas Brutas], ALL(dLocalidades))

VAR ShareCategoria =
CALCULATE([Vendas Brutas], ALL(dCategoriaProdutos[Categoria]))

RETURN
DIVIDE([Vendas Brutas], IF(ISFILTERED(dCategoriaProdutos[Categoria]), ShareCategoria, ShareContinente))

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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