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

Help to sum a measure

Hey guys!

 

I'm with a big problem and i hope that someone can help and i'll try to be more clear as possible.

 

I have the table below on my power bi:

 

Many columns are measure so i'm gonna detail each one with their dax expression:

Peso FR = CALCULATE(SUMX('LipsNF 2020', 'LipsNF 2020'[Peso_Bruto]), 'SKU - BIG C'[Sub Divisão II] = "FR")
Peso FS = CALCULATE(SUMX('LipsNF 2020', 'LipsNF 2020'[Peso_Bruto]), 'SKU - BIG C'[Sub Divisão II] = "FS")
Peso HC = CALCULATE(SUMX('LipsNF 2020', 'LipsNF 2020'[Peso_Bruto]), 'SKU - BIG C'[Sub Divisão II] = "HC")
Peso PC = CALCULATE(SUMX('LipsNF 2020', 'LipsNF 2020'[Peso_Bruto]), 'SKU - BIG C'[Sub Divisão II] = "PC")
Cap Total = CALCULATE(SUMX('Capacidade dos Veiculos', 'Capacidade dos Veiculos'[Capacidade (Tons)] * 1000 * [Count Veiculos]))
Ocio Veiculo = (([Cap Total] - SUMX('LipsNF 2020', 'LipsNF 2020'[Peso_Bruto])) / [Cap Total])
Ocupação = CALCULATE(DIVIDE(SUMX('LipsNF 2020', 'LipsNF 2020'[Peso_Bruto]),[Cap Total]), ALLSELECTED(Calendario))
Part FR = [Peso FR] / (CALCULATE([Peso FR], ALLselected(Calendario)))
Part FS = [Peso FS] / (CALCULATE([Peso FS], ALLselected(Calendario)))
Part HC = [Peso HC] / (CALCULATE([Peso HC], ALLselected('33N 2020')))
Part PC = [Peso PC] / (CALCULATE([Peso PC], ALLselected('33N 2020')))
Ocio FR = [Part FR] * [Ocupação]
Ocio FS = [Ocupação] * [Part FS]
Ocio HC = [Ocupação] * [Part HC]
Ocio PC = [Ocupação] * [Part PC]
 
I know, lot of measures haha
 
So what's the problem that i'm having?
On the columns/measures Ocio FR/Ocio FS/Ocio HC/Ocio PC i want to get the correclty sum of these columns when i filter the table.
The table is filtered so i believe that "66,90%" is wrong or it's the total sum of ALL THE TABLE without filter.
 
To make it more easly to understand, let's work only with the column Ocio HC.
If you add the entire column you gonna see 84,82%. But the total that is showing is 66,90% and i don't know why 🙂
So i'm trying to get this 84,82%.
 
If someone undestood all that and could help me, i'll appreciate it.
Or if it's not clear enought, please, let me know and i'll try to explain again.
 
 
 
Thanks.
3 REPLIES 3
Greg_Deckler
Super User
Super User

@Anonymous - This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Decklerthanks for your help but i'm, unfortunately, still don't get it.

 

I read the links and tried all that i know. I'm newbie on Power Bi so i didnt go so far.

 

I tried on column "Ocio HC" the following dax expressions:

Ocio HC = IF(HASONEFILTER(Calendario[Date].[Dia]), CALCULATE([Ocupação] * [Part HC ], ALLSELECTED('33N 2020')))
 
Ocio HC = IF(HASONEFILTER(Calendario[Date].[Dia]), CALCULATE([Ocupação] * [Part HC ], ALL(Calendario[Date].[Dia])))
 
Ocio HC = IF(HASONEFILTER(Calendario[Date].[Dia]), CALCULATE([Ocupação] * [Part HC], ALL(Calendario)))
 
Ocio HC = SUMX(FILTER(VALUES(Calendario[Date].[Dia]), Calendario[Date].[Dia]=31),[Ocupação]*[Part HC ])
 
Ocio HC =
VAR __table = SUMMARIZE(Calendario,Calendario[Date].[Dia],"__value",[Ocupação]*[Part HC ])
RETURN
IF(HASONEVALUE(Calendario[Date].[Dia]),[Ocupação]*[Part HC ],SUMX(__table,[__value]))
 
I tried to calculate on a new column but it didn't work too.
 
I'm out of options now 😞

@Anonymous - You'll have to post sample data. Please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors