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


Follow on LinkedIn
@ 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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.