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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
vijaykumarj19
Microsoft Employee
Microsoft Employee

Cumulative sum zero values should display previous values till end values

c1c2c3
may 20203232
jun 20202254
jul 2020 54
aug 2020 54
sept 20203488
oct 2020290
nov 2020  
dec 2020  

 

I have c2 column and need to display c3 running total but blank values before last value should display previous values

my table is connected to date table 

 

my measure:

CALCULATE(
    sum(c2),
    FILTER(
        CALCULATETABLE(
            SUMMARIZE(
                'Date Table',
                'Date Table'[cc_year-Month Sort],
                'Date Table'[Year Month]
            ),
            ALLSELECTED('Date Table')
        ),
        ISONORAFTER(
            'Date Table'[cc_year-Month Sort], MAX('Date Table'[cc_year-Month Sort]), DESC,
            'Date Table'[Year Month], MAX('Date Table'[Year Month]), DESC
        )
    )
)

 

but displaying cumulative till last 

 

1 ACCEPTED SOLUTION

@vijaykumarj19  try to change MAX to MIN

wdx223_Daniel_0-1604382572964.png

 

View solution in original post

12 REPLIES 12
BhushanR
New Member

If tried same scenario and try to filter the data by using slicer which I created from date field it is not giving correct count.

wdx223_Daniel
Super User
Super User

@vijaykumarj19 assume c1 from date table then try this code

=var _currentYM=max(datetable[year month]) return calculate(sum(c2),datetable[year month]<=_currentYM)

Its not showing cumulative count

My table

 

vijaykumarj19_0-1604276463991.png

 

calculating cumulative and ploted in line graph

 

Capture.PNG

Below line should stop at a6 

Dax :

c2 running total in c1 =
CALCULATE(
    SUM('Table'[c2]),
    FILTER(
        ALLSELECTED('Table'[c1]),
        ISONORAFTER('Table'[c1], MAX('Table'[c1]), DESC)
))
 
 

can anyone help me with the solution

@vijaykumarj19 

think you need a IF function

wdx223_Daniel_0-1604304526614.png

 

Need to show a3 and a4 with a2 value

@vijaykumarj19 

can this work?

wdx223_Daniel_0-1604305805491.png

 

If we have dates as axis

 

vijaykumarj19_1-1604320641085.png

If i have month year from date table as axis then 

 

vijaykumarj19_2-1604320731435.png

and i do have a relation between tables

 

vijaykumarj19_3-1604320798178.png

Then how would this dax modified 

var c = MAX('Table'[c1])
VAR d = MAXX(FILTER(ALL('Table'),'Table'[c2]>0),'Table'[c1])
Return
IF(c<=d,
CALCULATE(SUM('Table'[c2]),FILTER(ALL('Table'),'Table'[c1]<=c)))

 

 

@vijaykumarj19 

wdx223_Daniel_0-1604365885701.png

AccTotalc2 = VAR vCurrentDate=MAX(DateTable[Date]) VAR vMaxDate=CALCULATE(MAX('Fact'[c1]),FILTER(ALL('Fact'),'Fact'[c2]>0)) RETURN IF(vCurrentDate<=vMaxDate,CALCULATE(SUM('Fact'[c2]),DateTable[Date]<=vCurrentDate))
AccTotalc4 = VAR vCurrentDate=MAX(DateTable[Date]) VAR vMaxDate=CALCULATE(MAX('Fact'[c1]),FILTER(ALL('Fact'),'Fact'[c4]>0)) RETURN IF(vCurrentDate<=vMaxDate,CALCULATE(SUM('Fact'[c4]),DateTable[Date]<=vCurrentDate))

vijaykumarj19_1-1604375518984.png

But it stoped at dec need to be extended till Jan , Because we have value for Jan also 

vijaykumarj19_0-1604375648429.png

 

@vijaykumarj19  try to change MAX to MIN

wdx223_Daniel_0-1604382572964.png

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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