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
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
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.