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

YTD Cumulative for weekly figures

 Tonnes Last Year Tonnes This YearTonnes Last Year CumulativeTonnes This Year Cumulative
Week 1250238250238
Week 2300526550764
Week 3125114675878
Week 438253810571416
Week 540541014621826
Week 650823519702061
Week 713723321072294

 

I am trying to create measure for the cumulative columes. 

 

I have following ...

 

Tonnes 2020 cumulative = TotalYTD(sum('data table'[Tonnes]),'data table'[date],if('data table'[Year]=2020,2020,0))

 

It's returning weekly numbers by the week. Not YTD culmulative. 

 

Appreciate your help as always.

 

Jen

1 ACCEPTED SOLUTION

Hi @Anonymous ,

Please create one calculated column to get the week number first, then create one measure to cumulative the weekly tonnes. The related formulas as below:

Week = WEEKNUM('Scale date 2019 2020'[Date],2)
Tonnes 2019 cumulative = 
VAR curweek =
    MAX ( 'Scale date 2019 2020'[Week] )
RETURN
    CALCULATE (
        SUM ( 'Scale date 2019 2020'[Tonnes] ),
        FILTER (
            ALL ( 'Scale date 2019 2020' ),
            YEAR ( 'Scale date 2019 2020'[Date] ) = 2019
                && 'Scale date 2019 2020'[Week] <= curweek
        )
    )

culmutive.JPG

Best Regards

Rena

Community Support Team _ Rena
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

7 REPLIES 7
amitchandak
Super User
Super User

@Anonymous , Not sure on the need to if clause,

You should try like

Tonnes 2020 cumulative = TotalYTD(sum('data table'[Tonnes]),'data table'[date])

Prefer with a date table

Tonnes 2020 cumulative = TotalYTD(sum('data table'[Tonnes]),'Date'[date])

And Create week in your date table and use from there.

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

karun_r
Employee
Employee

Do you have a sample PBI that you can share to help us understand more

 

From what I can see, this should work. Please share a sample PBI if this is not working. Also you should have a seperate time dimension table for the time intelligence calculations to work properly. That's why I replaced your 'Data Table' with 'Time'  in my version.

 

Total YTD Cummulative  =  TOTALYTD(SUM('Data Table'[Tonnes], 'Time'[Date], KEEPFILTERS('Time'[Year] = 2020))

 

Anonymous
Not applicable

This is the data set and canvas...

 

Image 2.PNG

Hi @Anonymous ,

Please create one calculated column to get the week number first, then create one measure to cumulative the weekly tonnes. The related formulas as below:

Week = WEEKNUM('Scale date 2019 2020'[Date],2)
Tonnes 2019 cumulative = 
VAR curweek =
    MAX ( 'Scale date 2019 2020'[Week] )
RETURN
    CALCULATE (
        SUM ( 'Scale date 2019 2020'[Tonnes] ),
        FILTER (
            ALL ( 'Scale date 2019 2020' ),
            YEAR ( 'Scale date 2019 2020'[Date] ) = 2019
                && 'Scale date 2019 2020'[Week] <= curweek
        )
    )

culmutive.JPG

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

is the "week" week number or week starting date?

Hi @Anonymous ,

The return values of new created calculated column "Week" are week numbers.

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

It worked! Four days of struggle. Thank you!

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.