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
vijaykumarj19
Employee
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

11 REPLIES 11
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
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