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

comparison this year to STLY - but with multiple date columns to be looked at. (travel)

Hi, 

 

I have a SQL table where i have a lot of information regarding reservations from 2022 until today. 

What i want to do is create a Power BI dashboard where i can compare the amount of reservations made this year, versus the same time last year for specific arrival weeks. And also see for which day of the week these people would arrive. 

 

I tried using some dax formulas, but noticed that when I want to compare 2/1/2023 for example (a monday), it would compare to 2/1/2022 (a sunday). However, I want to compare mondays with Mondays as these have great influence on performance. 

The end goal is to have a slicer where i can select a date range for 2023 (e.g 2/1/2023 until 14/1/2023), and then see how many reservations were made for which arrival weeks, and compare that to the same time last year (3/1/2022 until 15/1/2023), for the same arrival weeks (not influenced by year). 

I've added a screenshot above how the data looks , and on the bottom what i would want the output to be.
example on top of how the data looks, bottom is what i want as outputexample on top of how the data looks, bottom is what i want as output

2 REPLIES 2
Anonymous
Not applicable

Hi  @Anonymous ,

 

Here are the steps you can follow:

1. Create calculated table.

Date =
CALENDAR(
    MIN('Table'[CreationDate]),
    MAX('Table'[CreationDate]))

2. Create measure.

reservations_ty =
var _mindate=MINX(ALLSELECTED('Date'),'Date'[Date])
var _maxdate=MAXX(ALLSELECTED('Date'),'Date'[Date])
return
COUNTX(
    FILTER(ALL('Table'),
    'Table'[CreationDate]>=_mindate&&'Table'[CreationDate]<=_maxdate&&'Table'[ArrivalDayofWeek]=MAX('Table'[ArrivalDayofWeek])&&'Table'[ArrivalWeekNum]=MAX('Table'[ArrivalWeekNum])),[ReservationID])
reservations_stly =
var _mindate=MINX(ALLSELECTED('Date'),'Date'[Date])
var _maxdate=MAXX(ALLSELECTED('Date'),'Date'[Date])
return
IF(
    [revenue_stly]<>BLANK(),
COUNTX(
    FILTER(ALL('Table'),    YEAR('Table'[CreationDate])=YEAR(_mindate)-1&&'Table'[ArrivalWeekNum]=MAX('Table'[ArrivalWeekNum])&&'Table'[ArrivalDayofWeek]=MAX('Table'[ArrivalDayofWeek])),[ReservationID]),BLANK())
revenue_stly =
var _mindate=MINX(ALLSELECTED('Date'),'Date'[Date])
var _maxdate=MAXX(ALLSELECTED('Date'),'Date'[Date])
return
SUMX(
    FILTER(ALL('Table'),
    'Table'[CreationDate]>=_mindate&&'Table'[CreationDate]<=_maxdate&&'Table'[ArrivalDayofWeek]=MAX('Table'[ArrivalDayofWeek])&&'Table'[ArrivalWeekNum]=MAX('Table'[ArrivalWeekNum])),[revenue])
revenue_stly_last =
var _mindate=MINX(ALLSELECTED('Date'),'Date'[Date])
var _maxdate=MAXX(ALLSELECTED('Date'),'Date'[Date])
return
IF(
    [revenue_stly]<>BLANK(),
SUMX(
    FILTER(ALL('Table'),   YEAR('Table'[CreationDate])=YEAR(_mindate)-1&&'Table'[ArrivalWeekNum]=MAX('Table'[ArrivalWeekNum])&&'Table'[ArrivalDayofWeek]=MAX('Table'[ArrivalDayofWeek])),[revenue]),BLANK())

3. Result:

vyangliumsft_0-1698224025699.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Anonymous
Not applicable

Hi @Anonymous , 

 

What do you mean with revenue_stly_last? I would expect a revenue and then revenue_stly column. 

also i tried your example by plugging in differnet numbers but then it didn't seem to work. See PBI file added. 


The output what i expect is below




ReservationIDCreationDateArrivalDateArrivalWeekNumArrivalDayofWeekHotelrevenue  
book-00103/01/202201/02/20225Tuesdayparis€ 100,00  
book-00203/01/202201/02/20225Tuesdayparis€ 487,00  
book-00303/01/202203/02/20225Thursdayparis€ 914,00  
book-00403/01/202201/02/20225Tuesdayparis€ 654,00  
book-00503/01/202201/02/20225Tuesdaylondon€ 122,00  
book-00603/01/202203/02/20225Thursdaylondon€ 607,00  
book-00703/01/202204/02/20225Fridaylondon€ 999,00  
book-00804/01/202204/02/20225Fridaylondon€ 591,00  
book-00904/01/202204/02/20225Fridaylondon€ 230,00  
book-01004/01/202204/02/20225Fridaylondon€ 178,00  
book-01104/01/202204/02/20225Fridayparis€ 282,00  
book-01204/01/202204/02/20225Fridaylondon€ 534,00  
book-02302/01/202331/01/20235Tuesdaylondon€ 688,00  
book-02402/01/202303/02/20235Thursdaylondon€ 178,00  
book-02502/01/202303/02/20235Tuesdaylondon€ 921,00  
book-02602/01/202303/02/20235Thursdaylondon€ 631,00  
book-02702/01/202303/02/20235Thursdaylondon€ 832,00  
book-02803/01/202303/02/20235Thursdayparis€ 413,00  
book-02903/01/202304/02/20235Fridayparis€ 324,00  
book-03003/01/202304/02/20235Fridayparis€ 868,00  
book-03103/01/202304/02/20235Fridaylondon€ 518,00  
book-03203/01/202304/02/20235Fridaylondon€ 592,00  

book-033

03/01/202304/02/20235Fridaylondon€ 762,00  

 

 

 

 

creationdateWeekNumArrivalDayofWeekhotelreservations_tyreservations_lyrevenue_tyrevenue_ly
02/01/20235Tuesdaylondon21€ 1.609,00€ 122,00
02/01/20235Thursdaylondon31€ 1.730,00€ 607,00
02/01/20235Fridaylondon01€ 0,00€ 999,00
02/01/20235Thursdayparis01€ 0,00€ 914,00
02/01/20235Tuesdayparis03€ 0,00€ 1.241,00
03/01/20235Thursdayparis10€ 413,00€ 0,00
03/01/20235Fridaylondon34€ 1.872,00€ 1.533,00
03/01/20235Fridayparis21€ 1.192,00€ 282,00

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