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
Explico
Frequent Visitor

Cumulative total vs last year stopping at today

I'm trying to make Total cumulative sales compared to the previous year's chart and I'm struggling to stop the chart:

Screenshot 2022-04-18 182639.png

My measure is as follows:

 

Cumulative sales = 
--current day of year:
var _max = datediff(date(year(maxX(allselected(SalesDB), SalesDB[Date])),1,1),maxX(allselected(SalesDB), SalesDB[Date]),DAY)+1
return
CALCULATE (
    sum(SalesDB[SalesAmount]),
    FILTER (
        ALL ( SalesDB ),
        SalesDB[Date] <= MAX (SalesDB[Date])
            && SalesDB[Day_of_year] <= _max  --add only this day of year
            && SalesDB[Year]=year(max(SalesDB[Date])) --resets yeach year
    )
)

 

 

Any idea - how to stop this chart at today's Day_of_year?

 

I do have a more simple measure which stops just fine, but it is not cumulative:

Screenshot 2022-04-18 184340.png

Sales till today = 
--current day of year
var _max = datediff(date(year(maxX(allselected(SalesDB), SalesDB[Date])),1,1),maxX(allselected(SalesDB), SalesDB[Date]),DAY)+1
return
calculate(sum(SalesDB[SalesAmount]), filter(SalesDB, SalesDB[Day_of_year]<=_max))

 

Thanks!

 

 

1 ACCEPTED SOLUTION
fhill
Resident Rockstar
Resident Rockstar

OK, here's my version of what you have...  

 

fhill_0-1650301095587.png

 

... and here's my IF Statement that DOES NOT do the Calcuatle math if Day_Of_Year in the talbe is Greater than Today's Day of Yyear....

fhill_1-1650301127334.png

 

 




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




View solution in original post

2 REPLIES 2
fhill
Resident Rockstar
Resident Rockstar

 

I'll start playing with the DAX code, but I'm thinking we'll have to add an IF statement, so that if the Day of Year is > Current Year, Day of Year, then BLANK(), else do you Culmative calculation?

 

Forrest

 

Cumulative sales = 
--current day of year:
var _max = datediff(date(year(maxX(allselected(SalesDB), SalesDB[Date])),1,1),maxX(allselected(SalesDB), SalesDB[Date]),DAY)+1
return
CALCULATE (
    sum(SalesDB[SalesAmount]),
    FILTER (
        ALL ( SalesDB ),
        SalesDB[Date] <= MAX (SalesDB[Date])
            && SalesDB[Day_of_year] <= _max  --add only this day of year
            && SalesDB[Year]=year(max(SalesDB[Date])) --resets yeach year
    )
)

 

 

 

 

 




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




fhill
Resident Rockstar
Resident Rockstar

OK, here's my version of what you have...  

 

fhill_0-1650301095587.png

 

... and here's my IF Statement that DOES NOT do the Calcuatle math if Day_Of_Year in the talbe is Greater than Today's Day of Yyear....

fhill_1-1650301127334.png

 

 




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
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.