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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
nardtmo
Helper III
Helper III

compare same day data to a fix date range

Hi

 

Hoping you guys can help.

Basically i want to use Week 27-29 as my comparison week/weekday for succeeding days. Say today is 8/28 friday, it will take friday data of week 27-29, average it and compare is to 8/28 friday data.

 

Thanks in advance!

 

 

     OutputOutput
 weekdaydate# CustomerBaseperiod Ave. # customerdelta
Baseline period27Sunday28-Jun23  
Baseline period27Monday29-Jun24  
Baseline period27Tuesday30-Jun3  
Baseline period27Wednesday1-Jul26  
Baseline period27Thursday2-Jul27  
Baseline period27Friday3-Jul28  
Baseline period27Saturday4-Jul56  
Baseline period28Sunday5-Jul30  
Baseline period28Monday6-Jul31  
Baseline period28Tuesday7-Jul4  
Baseline period28Wednesday8-Jul33  
Baseline period28Thursday9-Jul14  
Baseline period28Friday10-Jul35  
Baseline period28Saturday11-Jul9  
Baseline period29Sunday12-Jul2  
Baseline period29Monday13-Jul16  
Baseline period29Tuesday14-Jul56  
Baseline period29Wednesday15-Jul18  
Baseline period29Thursday16-Jul19  
Baseline period29Friday17-Jul20  
Baseline period29Saturday18-Jul21  
Future Data30Sunday19-Jul2218.333333333.666667
Future Data30Monday20-Jul323.66666667-20.6667
Future Data30Tuesday21-Jul24213
Future Data30Wednesday22-Jul2525.66666667-0.66667
Future Data30Thursday23-Jul420-16
Future Data30Friday24-Jul2727.66666667-0.66667
Future Data30Saturday25-Jul328.66666667-25.6667
Future Data31Sunday26-Jul2918.3333333310.66667
Future Data31Monday27-Jul023.66666667-23.6667
Future Data31Tuesday28-Jul312110
Future Data31Wednesday29-Jul3225.666666676.333333
Future Data31Thursday30-Jul1820-2
Future Data31Friday31-Jul527.66666667-22.6667
Future Data31Saturday1-Aug2928.666666670.333333
Future Data32Sunday2-Aug1418.33333333-4.33333
Future Data32Monday3-Aug223.66666667-21.6667
Future Data32Tuesday4-Aug1621-5
Future Data32Wednesday5-Aug1725.66666667-8.66667
Future Data32Thursday6-Aug720-13
Future Data32Friday7-Aug327.66666667-24.6667
Future Data32Saturday8-Aug2028.66666667-8.66667
Future Data33Sunday9-Aug118.33333333-17.3333
Future Data33Monday10-Aug2223.66666667-1.66667
Future Data33Tuesday11-Aug321-18
Future Data33Wednesday12-Aug2425.66666667-1.66667
Future Data33Thursday13-Aug562036
Future Data33Friday14-Aug827.66666667-19.6667
Future Data33Saturday15-Aug2728.66666667-1.66667
Future Data34Sunday16-Aug2818.333333339.666667
Future Data34Monday17-Aug023.66666667-23.6667
Future Data34Tuesday18-Aug621-15
Future Data34Wednesday19-Aug3125.666666675.333333
Future Data34Thursday20-Aug220-18
Future Data34Friday21-Aug3327.666666675.333333
Future Data34Saturday22-Aug328.66666667-25.6667
Future Data35Sunday23-Aug3518.3333333316.66667
Future Data35Monday24-Aug3623.6666666712.33333
Future Data35Tuesday25-Aug121-20
Future Data35Wednesday26-Aug3825.6666666712.33333
Future Data35Thursday27-Aug802060
Future Data35Friday28-Aug1027.66666667-17.6667
1 ACCEPTED SOLUTION
vivran22
Community Champion
Community Champion

@nardtmo 

 

You may use the following measures:

 

Average Last 3 weeks = 
VAR _CurrentDate =
    MAX ( 'Table'[date] )
VAR _Weekday =
    WEEKDAY ( _CurrentDate, 2 )
VAR _MinDate =
    CALCULATE ( MIN ( 'Table'[date] ), ALL ( 'Table'[date] ) )
VAR _Average =
    IF (
        _CurrentDate >= _MinDate + 21,
        CALCULATE (
            AVERAGE ( 'Table'[# Customer] ),
            DATESINPERIOD ( 'Table'[date], _CurrentDate - 1, -21, DAY ),
            WEEKDAY ( 'Table'[date], 2 ) = _Weekday
        )
    )
RETURN
    _Average




Difference = 
VAR _CurrentDate =
    MAX ( 'Table'[date] )
VAR _MinDate =
    CALCULATE ( MIN ( 'Table'[date] ), ALL ( 'Table'[date] ) )
VAR _Difference =
    IF (
        _CurrentDate >= _MinDate + 21,
        MAX ( 'Table'[# Customer] ) - [Average Last 3 weeks]
    )
RETURN
    _Difference

 

 

Output

image.png

Cheers!
Vivek

Blog: vivran.in/my-blog
Connect on LinkedIn
Follow on Twitter

View solution in original post

8 REPLIES 8
Greg_Deckler
Community Champion
Community Champion

@nardtmo - I *think* you want something like:

Measure =
  VAR __Weekday = MAX('Table'[day])
  VAR __Baseline = AVERAGEX(FILTER(ALL('Table'),([week] = "Baseline period27" || [week] = "Baseline period28" || [week] = "Baseline period29") && [day]=__Weekday),[#])
  VAR __Current = MAX('Table'[#])
RETURN
  __Current - __Baseline

 



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

 

Thanks for the reply. if you have time pls take a look at the pbix. I added date table and use a measure to sum all customers. the plan is, i should be able to compare daily #of customer from baseline period as well as  compare daily# of customer from specific stores (same calculation) 

 

I'm getting error

 

Delta = VAR __Weekday = MAX('Date Table'[day name])
VAR __Baseline = AVERAGEX(FILTER(ALL('Date Table'[week]),([week] = 27 || [week] = 28 || [week] = 29) && [day]=__Weekday),[sum of customers])
VAR __Current = MAX([sum of customers])
RETURN
__Current - __Baseline
 
error ="Column 'day' cannot be bound or not be use in this expression"
 
 

https://drive.google.com/file/d/1DbPDD5-2ZcKrP2U36Cs5r6vY0smQAniS/view?usp=sharing

 

thanks again.
vivran22
Community Champion
Community Champion

Hello @nardtmo ,

 

Unable to access the file as the access is denied.

 

Cheers!
Vivek

Blog: vivran.in/my-blog
Connect on LinkedIn
Follow on Twitter

 

Helloo

uploaded it in dropbox.

 

 

https://www.dropbox.com/s/kcoau2k2vd7xvsk/delta.pbix?dl=0

 

vivran22
Community Champion
Community Champion

@nardtmo 

I can access the file. Can you explain how did you get 18.33 as Baseperiod Ave. # customer?

 

Cheers!
Vivek

Blog: vivran.in/my-blog
Connect on LinkedIn
Follow on Twitter

18.33 it's the average of all Sundays of WK 27,28, & WK 29

vivran22
Community Champion
Community Champion

@nardtmo 

 

You may use the following measures:

 

Average Last 3 weeks = 
VAR _CurrentDate =
    MAX ( 'Table'[date] )
VAR _Weekday =
    WEEKDAY ( _CurrentDate, 2 )
VAR _MinDate =
    CALCULATE ( MIN ( 'Table'[date] ), ALL ( 'Table'[date] ) )
VAR _Average =
    IF (
        _CurrentDate >= _MinDate + 21,
        CALCULATE (
            AVERAGE ( 'Table'[# Customer] ),
            DATESINPERIOD ( 'Table'[date], _CurrentDate - 1, -21, DAY ),
            WEEKDAY ( 'Table'[date], 2 ) = _Weekday
        )
    )
RETURN
    _Average




Difference = 
VAR _CurrentDate =
    MAX ( 'Table'[date] )
VAR _MinDate =
    CALCULATE ( MIN ( 'Table'[date] ), ALL ( 'Table'[date] ) )
VAR _Difference =
    IF (
        _CurrentDate >= _MinDate + 21,
        MAX ( 'Table'[# Customer] ) - [Average Last 3 weeks]
    )
RETURN
    _Difference

 

 

Output

image.png

Cheers!
Vivek

Blog: vivran.in/my-blog
Connect on LinkedIn
Follow on Twitter

Thanks so much!!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors