Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

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
v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

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.
Anonymous
Not applicable

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.