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

Running total problem - not summing with zero

My running total script is not summing correctly values with 0.

 

**bleep** PoD 30 =
VAR vMax = MAX(Arkusz1[PoD30])
RETURN
       CALCULATE(
                     SUM(Arkusz1[Default30]),
                     FILTER(ALL(Arkusz1[PoD30]),
                     Arkusz1[PoD30] <= vMax)
)

 
In my rows I have dates, and in columns I have PoD30. For every next value for PoD30 I would like to sum values from Default30 column which is representing 1 or 0 (default or not). For October 2020 I have 0 in 6-th month (column) where I should have still 6 value as this is correct running sum from 0 to 6 month. 7-th month is summing correctly. What should I correct to get right numbers? 
 
seko86_0-1627643935211.png

 

 This is how looks like a table with particular columns/measures. I think problem is because I have blank values for October 2020 in 6-th month.  

 

seko86_0-1627644957270.png

 

Instead I tried to use measure: Defaulted - where I can see 0 but still I can't get the right values:

 

PoD 30 =
VAR vMax = MAX(Arkusz1[PoD30])
RETURN
       CALCULATE(
                     SUMX(Arkusz1, Arkusz1[Defaulted]),
                     FILTER(ALL(Arkusz1[PoD30]),
                     Arkusz1[PoD30] <= vMax)
)
2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Try like

 

**bleep** PoD 30 =
VAR vMax = MAX(Arkusz1[PoD30])
RETURN


CALCULATE(
SUM(Arkusz1[Default30]),
FILTER(ALL(Arkusz1),
Arkusz1[PoD30] <= vMax && Arkusz1[Date] = max(Arkusz1[Date])
))

 

 

or

**bleep** PoD 30 =
VAR vMax = MAX(Arkusz1[PoD30])
RETURN
CALCULATE(
SUM(Arkusz1[Default30]),
FILTER(ALL(Arkusz1),
Arkusz1[PoD30] <= vMax && Arkusz1[year] = max(Arkusz1[year]) && Arkusz1[month] = max(Arkusz1[month])
))

Anonymous
Not applicable

I cannot add Arkusz1[date] to the Filter part as it's not a measure but just a column.

 

There you have sample data in table:

 

YearMonthPoD30**bleep** PoD 30Default30Defaulted
2020September0000
2020September20 0
2020September3222
2020September40 0
2020September5311
2020September6522
2020September70 0
2020September80 0
2020September90 0
2020October0000
2020October2111
2020October3211
2020October4422
2020October5622
2020October60 0
2020October7822
2020October8911
2020October91122
2020November0000
2020November20 0
2020November3333
2020November4522
2020November50 0
2020November6833
2020November71133
2020November80 0
2020November90 0
2020December0000
2020December2222
2020December3533
2020December4611
2020December5822
2020December6911
2020December70 0
2020December80 0
2020December90 0

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.