cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

How can I use DAX to SUM values attached to two specific date periods?

Hi,

 

I need to create a measure that will SUM a sales value on a selected date, lets say 03/03/2018, then subtract the SUM of this same value on the selected date -1 day.

 

Any help appreciated.

2 REPLIES 2
Microsoft
Microsoft

Hi @aspnet-scotland,

 

Can you share a sample please? That depends on how you will create your report.

The measure below could help.

Result =
VAR lastday =
    CALCULATE (
        SUM ( FactSales[SalesQuantity] ),
        FILTER (
            ALL ( DimDate[Datekey] ),
            DimDate[Datekey]
                = MIN ( DimDate[Datekey] ) - 1
        )
    )
RETURN
    SUM ( FactSales[SalesQuantity] ) - lastday

How_can_I_use_DAX_to_SUM_values_attached_to_two_specific_date_periods

 

Best Regards,

Dale

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

Thanks for your reply. Unfortunately your solution doesn't perform the subtraction.

 

For example:

 

My "SalesQuantity" for 05/03/2018 is -0.03097

My "SalesQuantity" for the proceeding date 02/03/2018 is -0.04047

 

The above should result in: 0.0095 (-0.03097 - -0.04047) but your measure results in -0.03 when 05/03/2018 is the selected date.

 

Thanks.

Helpful resources

Announcements
November Update

Check it Out!

Click here to read more about the November 2020 Updates!

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform October Community Highlights

Check out the top community contributors across all of the communities

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors