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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

How to get cumulative value only by one column

Hi, I want to create a YTD and there is some trouble when use TOTALYTD and DATESYTD, so I want to use calculate instead, 

here is the result someone told me, but there is a problem that when added another column, the YTD does not goes well, I want the YTD just cumulatived by date column whatever other column added,  is there a measure or column can solve it?

here is the calculation 

VAR _current_date =
    MAX ('Query1'[date])
VAR _current_year =
    YEAR ( _current_date )
RETURN
    CALCULATE (
        SUM('Query1'[value]),
        YEAR ( 'Query1'[date] ) = _current_year,
        'Query1'[date]<= _current_date
    )
and when added REMOVEFILTERS('Query1'[week]) , REMOVEFILTERS('Query1') or ALLEXCEPT('Query1','Query1'[date]) in calculation still did not get expected result

there is no problem with the YTD when no column add

 

after add the week column, YTD fails to goes well

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

I made a change on your code, you can try it:

 

measure = VAR _current_date =
    MAX ('Query1'[date])
VAR _current_year =
    YEAR ( _current_date )
RETURN
    CALCULATE (
        SUM('Query1'[value]),
       FILTER(ALLSELECTED(Query1),YEAR(Query1[date])=_current_year&&Query1[date]<=_current_date)
    )

 

vxinruzhumsft_0-1673228643427.png

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Create a Calendar table.  Create a relationship (Many to One and Single) from the Date column of your Data Table to the Date column of the Calendar Table.  To your visual, drag Date from the Calendar Table.  Write these measures

Total = SUM('Query1'[value])

Total YTD = calculate([Total],datesytd(calendar[Date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi @Anonymous 

I made a change on your code, you can try it:

 

measure = VAR _current_date =
    MAX ('Query1'[date])
VAR _current_year =
    YEAR ( _current_date )
RETURN
    CALCULATE (
        SUM('Query1'[value]),
       FILTER(ALLSELECTED(Query1),YEAR(Query1[date])=_current_year&&Query1[date]<=_current_date)
    )

 

vxinruzhumsft_0-1673228643427.png

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , prefer to use a date table and new window function

explore Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc

 

or use a measure like

 

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(all('Date'),'Date'[date] <=max('Date'[date])))

 

or

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(allselected(date),date[date] <=max(date[Date])))

 

 

Use date table in viusal and filter

 

Running Total/ Cumulative: https://www.youtube.com/watch?v=h2wsO332LUo&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=41

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors