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
gheecalipes25
Helper II
Helper II

this week versus last week difference

I have a table below in which i wanted to calculate or get the difference from this week's count against last week. below is a sample table output that i wanted to achieve. i wanted to get a dax formula for the Week Difference. Thank you in advance.

 

CountOfECMsWEEKENDINGSATWeek Difference
2112/2/2017 
3012/9/20179
3312/16/20173
1112/23/2017-22
812/30/2017-3
111/6/20183
251/13/201814
321/20/20187
161/27/2018-16
172/3/20181
252/10/20188
202/17/2018-5
222/24/20182
193/3/2018-3
173/10/2018-2
1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @gheecalipes25 

Please try formula like:

Week Difference = 
VAR last_week =
    CALCULATE (
        MAX ( 'Table'[WEEKENDINGSAT] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[WEEKENDINGSAT] < MAX ( 'Table'[WEEKENDINGSAT] )
        )
    )
VAR _count_of_lastweek =
    CALCULATE (
        [CountOfECMs1],
        FILTER ( ALL ( 'Table' ), 'Table'[WEEKENDINGSAT] = last_week )
    )
RETURN
    IF (
        ISBLANK ( _count_of_lastweek ),
        BLANK (),
        [CountOfECMs1] - _count_of_lastweek
    )

Best Regards,
Community Support Team _ Eason

View solution in original post

2 REPLIES 2
v-easonf-msft
Community Support
Community Support

Hi, @gheecalipes25 

Please try formula like:

Week Difference = 
VAR last_week =
    CALCULATE (
        MAX ( 'Table'[WEEKENDINGSAT] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[WEEKENDINGSAT] < MAX ( 'Table'[WEEKENDINGSAT] )
        )
    )
VAR _count_of_lastweek =
    CALCULATE (
        [CountOfECMs1],
        FILTER ( ALL ( 'Table' ), 'Table'[WEEKENDINGSAT] = last_week )
    )
RETURN
    IF (
        ISBLANK ( _count_of_lastweek ),
        BLANK (),
        [CountOfECMs1] - _count_of_lastweek
    )

Best Regards,
Community Support Team _ Eason

Greg_Deckler
Super User
Super User

@gheecalipes25 Easiest way would be to use a Sequential column: Sequential - Microsoft Power BI Community


@ 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.