Forum Discussion

DAX_Noob8212's avatar
DAX_Noob8212
New Member
2 years ago
Solved

Calculating daily number changes

Hi Team, I have a simple table with 4 rows.

 

Snapshot_datenew_enrreturning_enrtotal_enr
15/09/202310050150
16/09/2023200100300
17/09/2023300150450
18/09/2023400200600
19/09/2023500250750
20/09/2023600300900

 

I tried a few different codes but it's not working.

I just need a code to calculate the daily changes in numbers across these dates for 'new_enr' ,'returning_enr' and 'total_enr'.
So for example for daily changes in number for new_enr 1for the 16/09/23 would be 100 since its 100 more than 15/09/23 and likewise 50 for 'returning_enr' and  150 for'total_enr'.

 

Thanks all.

  • Hi DAX_Noob8212 for column total_enr to get daily change do following
    Create Calendar / Date table and connect with your table

    Create following measure (3) and you will get Output

    Did I answer correctly? Kudos appreciate / accept solution.

     

    Sum of total enr measure = SUM(Sheet1[total_enr])
    sum total enr previous measure =
    CALCULATE(
       SUM(Sheet1[total_enr]),
        DATEADD('Date'[Date],-1,DAY)
    )
    diff total enr measure =
    VAR __total_enr=[Sum of total enr measure]
    VAR __total_enr_prev=[sum total enr previous measure]
    RETURN __total_enr-__total_enr_prev

    Output

     

2 Replies

  • some_bih's avatar
    some_bih
    Community Champion

    Hi DAX_Noob8212 for column total_enr to get daily change do following
    Create Calendar / Date table and connect with your table

    Create following measure (3) and you will get Output

    Did I answer correctly? Kudos appreciate / accept solution.

     

    Sum of total enr measure = SUM(Sheet1[total_enr])
    sum total enr previous measure =
    CALCULATE(
       SUM(Sheet1[total_enr]),
        DATEADD('Date'[Date],-1,DAY)
    )
    diff total enr measure =
    VAR __total_enr=[Sum of total enr measure]
    VAR __total_enr_prev=[sum total enr previous measure]
    RETURN __total_enr-__total_enr_prev

    Output