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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
prove89
New Member

Running totals - showing only positive values - split positive and negative

Hi, 

 

I'm a new user having problem with dax XD.

I see that the best practise to get a dynamic running total in power BI is make a measure like this: 

 

Prog NEW Week =
calculate([Fabbisogno], filter(allselected('Date Confirmed'), 'Date Confirmed'[ISO YYWW]<=MAX('Date Confirmed'[ISO YYWW])))
 
where [Fabbisogno] is another measure:
Fabbisogno = SUM(MRPOUT[QTA_FABB])
 
In this way i get a matrix by material with the running total in every week.
Now I'm looking for a solution to get for every week the sum of positive running total. This should be a classic problem in powerBI, in fact in my data model I've inventory balances, purchasing orders and material needs (the future of inventory) and I'm trying to get the value of my inventory divided in eccess of inventory and lack of inventoy.
 
so i try to get this result with an if:
Prog NEW Week Valore Positivi =
IF([Prog NEW Week]>0, [Prog NEW Week], BLANK())
 
In every row of the matrix that meausure shows the correct result but the total is wrong.
 
That is an example of the first running total with positive and negative values.
prove89_1-1679677181789.png

 

I need to get a table like this:
prove89_2-1679677342196.png

 

 I see that with a measure like this i get the correct total in every row:
Positivi totale = SUMX(FILTER(ALLSELECTED(MRPOUT[K]), [Prog NEW Week]>0), [Prog NEW Week])
 
How can i get positive running totals by week / material
Thanks in advance
 
 
2 REPLIES 2
Greg_Deckler
Super User
Super User

@prove89 First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

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

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8


Follow on LinkedIn
@ 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...

Thanks Greg.

I've voted the idea. I'm actually a qlik developer and "show total as sum of row" is the solution that qlik used to get the result i'm expecting. 

I appreciate your help but I get the same result with HASONEFILTER.

Maybe I'm doing something wrong:

 

Prog NEW Week Valore Positivi=
IF(HASONEFILTER('Date Confirmed'[ISO YYWW]), if([Prog NEW Week]>0, [Prog NEW Week], BLANK()),
sumx(filter(MRPOUT, [Prog NEW Week]>0), [Prog NEW Week])
)
 
Thanks in advance

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Users online (1,179)