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
DemingPDCA
Helper I
Helper I

Cumulative Scrap Cost - Only show this year

I am trying to show cumulative scrap cost for only this year but my data has multiple years worth of information in it. I'm very close - and but its starting at the amount that I started the year with. I'd like to show this same thing, but have January 1 start at 0. I think my cumulative scrap formula must need another and statement? But I can't seem to get it right. 

Scrap Cost is the individual line items in my table, Scrap date is the day in that table that correlates to that cost, and calendar is just built out DAX Calendar 

 

Cumulative Scrap = 
CALCULATE(
    SUM(DMR_Scrap[ScrapCost]), FILTER(ALLSELECTED(DMR_Scrap), DMR_Scrap[ScrapDate Only] <= Max('Calendar'[Date]) && Date(2023, 1,1) <= Max('Calendar'[Date])))

 



DemingPDCA_0-1678990931095.png


Not sure this one is necessary to solve - but for reference!

 

Calendar = 
VAR 
    _startDate = EDATE(Today(), -14)
VAR
    _endDate = EDATE(TODAY(), 0)
RETURN
    ADDCOLUMNS(CALENDAR(_startDate, _endDate)
    , "Year", Year([Date])
    , "Year Month", YEAR([Date]) & " " & FORMAT([Date], "mmm")
    , "Quarter", "Q" & QUARTER([Date])
    , "Month Number", MONTH([Date])
    , "Month", FORMAT([Date], "mmm")
    , "Week", WEEKNUM([Date], 1)
    , "Year - Week", Year([Date]) & " " & WEEKNUM([Date])
    , "Day", Day([Date])
    , "Date Slicer"
        , IF([Date] = TODAY(), "Today"
            , IF([Date] = TODAY() - 1, "Yesterday"
            , FORMAT([Date], "mm/dd/yyyy") & ""
            )
        )
)

 

 

1 REPLY 1
Greg_Deckler
Super User
Super User

@DemingPDCA Try:

Cumulative Scrap = 
CALCULATE(
    SUM(DMR_Scrap[ScrapCost]), FILTER(ALLSELECTED(DMR_Scrap), DMR_Scrap[ScrapDate Only] <= Max('Calendar'[Date]) && Date(2023, 1,1) <= Max('Calendar'[Date]))) + 0

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.