2

I want to get the sum between two slicer dates without breaking it out by month. The number should be static for the dates selected.

Here's an example of the data I'm trying to get information from:

Date Disposal Method Weight (lb)
1/1/2024 Recycle 150
1/1/2024 Landfill 100
2/1/2024 Recycle 225
2/1/2024 Landfill 175
3/1/2024 Recycle 125
3/1/2024 Landfill 75
TOTAL 850
Date Production (lbs)
1/1/24 750
2/1/24 500
3/1/24 75
TOTAL 1,325

I have a _Calendar table for 1/1/24 - 12/31/24.

I want to get the landfill intensity (landfill lbs/production lbs to be dynamic with a date slicer. If the dates selected were 1/1/2024 - 2/28/24. The static intensity should be (100 [Jan landfill] + 175 [Feb landfill]) / (750 [Jan Prod] + 500 [Feb Prod]) = 0.22

I'm trying to get the following table:

Date Landfill Intensity of Dates Selected
1/1/24 0.22
2/1/24 0.22

I've tried this:

Landfill_Intensity = 
    CALCULATE(
        sum('Waste'[Weight (lbs)]),
            'Waste'[Disposal Method] = "landfill",
            DATESBETWEEN('Waste'[Date],FIRSTDATE(_Calendar[Date]),LASTDATE(_Calendar[Date]))      
    )    

/

CALCULATE(
    sum(Production[Weight (lbs)]), 
        DATESBETWEEN(Production[Date], FIRSTDATE(_Calendar[Date]),LASTDATE(_Calendar[Date]))
    )

and the intensity is still dependent on date:

Date Landfill Intensity of Dates Selected
1/1/24 0.13 [100/750]
2/1/24 0.35 [175/500]

How can I make the intensity take values in the slicer but apply a static value for values within the date slicer?

1 Answer 1

0

Can you try this below-

Landfill_Intensity = 


CALCULATE(
    sum('Waste'[Weight (lb)]),
    'Waste'[Disposal Method] = "landfill",
    DATESBETWEEN(
        'Waste'[Date],
        FIRSTDATE('calendar'[Date]),
        LASTDATE('calendar'[Date])
    )        
)    

/

CALCULATE(
    sum(Production[Production (lbs)]), 
    FILTER(
        ALL(Production[Date]),
        Production[Date] >= FIRSTDATE('calendar'[Date])
            && Production[Date] <= LASTDATE('calendar'[Date])
        
    )
)
        

Output-

enter image description here

Hope your Production and Waste tables are connected to _calendar table this below way using Date column-

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.