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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Kat2014
New Member

Weekly comparison YOY

Hello all,

I’m new to Power BI and was wondering if someone could help me with this. I watched some videos on it and read a few things online, but it didn’t quite match what I’d like to achieve.  I’m not familiar with all the Power BI terms just yet so be nice haha.

I’ve got two spreadsheets containing the following information.

First spreadsheet

  • Booking date
  • Brand
  • Revenue
  • People travelling
  • Travel date
  • Salesperson

Second spreadsheet

  • Booking date
  • Revenue targets for each day for this FY and next FY that are based on different brands. Our FY runs from September to August, not sure if that’s relevant

 

I’d like to create a table and visual that will show the revenue per week per brand for the last 4 weeks (Mon-Sun) and the same dates last year and compare them to this year’s target.

For example, booking week 22.7.24 – 28.7.24 compared to 22.7.23 – 28.7.23, even though last year it wasn’t Mon-Sun. It should always show the last 4 weeks (Mon-Sun) when updating the data. I’m struggling with it as we don’t compare week numbers.

The X axis should show 4 bars reflecting the last 4 weeks Mon-Sun (8.7 - 14.7.24; 15.7. – 21.7.24; 22.7. – 28.7.24 and 29.7. 4.8.24, for example), a bar next to it with the same dates but for 2023 and a bar with the targets for this year. The Y axis should show the revenue.

Is that possible?

Any help is appreciated. If you can point me in the right direction that would be amazing. Thank you very much for your help in advance. I hope the above makes sense.

 

Thank you 😊

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Kat2014 

 

Here I create a set of sample:

Revenue Table:

vzhengdxumsft_0-1723180353319.png

Target Table:

vzhengdxumsft_1-1723180359681.png

Then add a calculated table:

Table 2 = {1,2,3,4}

vzhengdxumsft_3-1723180445384.png

add a calculated column in table 2:

weeks =
VAR _currentValue = 'Table 2'[Value]
VAR _vtable =
    ADDCOLUMNS (
        CALENDAR ( MIN ( 'Revenue'[Booking date] ), MAX ( 'Revenue'[Booking date] ) ),
        "_Weekday", WEEKDAY ( [Date], 2 ),
        "_WeekNum", WEEKNUM ( [Date], 2 )
    )
VAR _NowNumber =
    MAXX ( FILTER ( _vtable, [Date] = TODAY () ), [_WeekNum] )
RETURN
    MINX (
        FILTER (
            _vtable,
            YEAR ( [Date] ) = YEAR ( TODAY () )
                && [_WeekNum] = _NowNumber - _currentValue
        ),
        [Date]
    ) & "--"
        & MAXX (
            FILTER (
                _vtable,
                YEAR ( [Date] ) = YEAR ( TODAY () )
                    && [_WeekNum] = _NowNumber - _currentValue
            ),
            [Date]
        )

vzhengdxumsft_4-1723180483949.png

At last, add 3 measure:

2024_revenue =
VAR _currentValue =
    SELECTEDVALUE ( 'Table 2'[Value] )
VAR _vtable =
    ADDCOLUMNS (
        CALENDAR ( MIN ( 'Revenue'[Booking date] ), MAX ( 'Revenue'[Booking date] ) ),
        "_Weekday", WEEKDAY ( [Date], 2 ),
        "_WeekNum", WEEKNUM ( [Date], 2 )
    )
VAR _NowNumber =
    MAXX ( FILTER ( _vtable, [Date] = TODAY () ), [_WeekNum] )
VAR _mindate =
    MINX (
        FILTER (
            _vtable,
            YEAR ( [Date] ) = YEAR ( TODAY () )
                && [_WeekNum] = _NowNumber - _currentValue
        ),
        [Date]
    )
VAR _maxdate =
    MAXX (
        FILTER (
            _vtable,
            YEAR ( [Date] ) = YEAR ( TODAY () )
                && [_WeekNum] = _NowNumber - _currentValue
        ),
        [Date]
    )
RETURN
    CALCULATE (
        SUM ( Revenue[Revenue] ),
        FILTER (
            ALLSELECTED ( Revenue ),
            'Revenue'[Booking date] >= _mindate
                && 'Revenue'[Booking date] <= _maxdate
        )
    )
2023_revenue =
VAR _currentValue =
    SELECTEDVALUE ( 'Table 2'[Value] )
VAR _vtable =
    ADDCOLUMNS (
        CALENDAR ( MIN ( 'Revenue'[Booking date] ), MAX ( 'Revenue'[Booking date] ) ),
        "_Weekday", WEEKDAY ( [Date], 2 ),
        "_WeekNum", WEEKNUM ( [Date], 2 )
    )
VAR _NowNumber =
    MAXX ( FILTER ( _vtable, [Date] = TODAY () ), [_WeekNum] )
VAR _mindate =
    MINX (
        FILTER (
            _vtable,
            YEAR ( [Date] ) = YEAR ( TODAY () )
                && [_WeekNum] = _NowNumber - _currentValue
        ),
        [Date]
    )
VAR _maxdate =
    MAXX (
        FILTER (
            _vtable,
            YEAR ( [Date] ) = YEAR ( TODAY () )
                && [_WeekNum] = _NowNumber - _currentValue
        ),
        [Date]
    )
RETURN
    CALCULATE (
        SUM ( Revenue[Revenue] ),
        FILTER (
            ALLSELECTED ( Revenue ),
            'Revenue'[Booking date]
                >= DATE ( YEAR ( _mindate ) - 1, MONTH ( _mindate ), DAY ( _mindate ) )
                && 'Revenue'[Booking date]
                    <= DATE ( YEAR ( _maxdate ) - 1, MONTH ( _maxdate ), DAY ( _maxdate ) )
        )
    )
2024_target =
VAR _currentValue =
    SELECTEDVALUE ( 'Table 2'[Value] )
VAR _vtable =
    ADDCOLUMNS (
        CALENDAR ( MIN ( 'Revenue'[Booking date] ), MAX ( 'Revenue'[Booking date] ) ),
        "_Weekday", WEEKDAY ( [Date], 2 ),
        "_WeekNum", WEEKNUM ( [Date], 2 )
    )
VAR _NowNumber =
    MAXX ( FILTER ( _vtable, [Date] = TODAY () ), [_WeekNum] )
VAR _mindate =
    MINX (
        FILTER (
            _vtable,
            YEAR ( [Date] ) = YEAR ( TODAY () )
                && [_WeekNum] = _NowNumber - _currentValue
        ),
        [Date]
    )
VAR _maxdate =
    MAXX (
        FILTER (
            _vtable,
            YEAR ( [Date] ) = YEAR ( TODAY () )
                && [_WeekNum] = _NowNumber - _currentValue
        ),
        [Date]
    )
RETURN
    CALCULATE (
        SUM ( Target[Revenue target] ),
        FILTER (
            ALLSELECTED ( 'Target' ),
            'Target'[Booking date] >= _mindate
                && 'Target'[Booking date] <= _maxdate
        )
    )

The result is as follow:

vzhengdxumsft_5-1723180579107.png

 

 

Best Regards

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

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Kat2014 

 

Here I create a set of sample:

Revenue Table:

vzhengdxumsft_0-1723180353319.png

Target Table:

vzhengdxumsft_1-1723180359681.png

Then add a calculated table:

Table 2 = {1,2,3,4}

vzhengdxumsft_3-1723180445384.png

add a calculated column in table 2:

weeks =
VAR _currentValue = 'Table 2'[Value]
VAR _vtable =
    ADDCOLUMNS (
        CALENDAR ( MIN ( 'Revenue'[Booking date] ), MAX ( 'Revenue'[Booking date] ) ),
        "_Weekday", WEEKDAY ( [Date], 2 ),
        "_WeekNum", WEEKNUM ( [Date], 2 )
    )
VAR _NowNumber =
    MAXX ( FILTER ( _vtable, [Date] = TODAY () ), [_WeekNum] )
RETURN
    MINX (
        FILTER (
            _vtable,
            YEAR ( [Date] ) = YEAR ( TODAY () )
                && [_WeekNum] = _NowNumber - _currentValue
        ),
        [Date]
    ) & "--"
        & MAXX (
            FILTER (
                _vtable,
                YEAR ( [Date] ) = YEAR ( TODAY () )
                    && [_WeekNum] = _NowNumber - _currentValue
            ),
            [Date]
        )

vzhengdxumsft_4-1723180483949.png

At last, add 3 measure:

2024_revenue =
VAR _currentValue =
    SELECTEDVALUE ( 'Table 2'[Value] )
VAR _vtable =
    ADDCOLUMNS (
        CALENDAR ( MIN ( 'Revenue'[Booking date] ), MAX ( 'Revenue'[Booking date] ) ),
        "_Weekday", WEEKDAY ( [Date], 2 ),
        "_WeekNum", WEEKNUM ( [Date], 2 )
    )
VAR _NowNumber =
    MAXX ( FILTER ( _vtable, [Date] = TODAY () ), [_WeekNum] )
VAR _mindate =
    MINX (
        FILTER (
            _vtable,
            YEAR ( [Date] ) = YEAR ( TODAY () )
                && [_WeekNum] = _NowNumber - _currentValue
        ),
        [Date]
    )
VAR _maxdate =
    MAXX (
        FILTER (
            _vtable,
            YEAR ( [Date] ) = YEAR ( TODAY () )
                && [_WeekNum] = _NowNumber - _currentValue
        ),
        [Date]
    )
RETURN
    CALCULATE (
        SUM ( Revenue[Revenue] ),
        FILTER (
            ALLSELECTED ( Revenue ),
            'Revenue'[Booking date] >= _mindate
                && 'Revenue'[Booking date] <= _maxdate
        )
    )
2023_revenue =
VAR _currentValue =
    SELECTEDVALUE ( 'Table 2'[Value] )
VAR _vtable =
    ADDCOLUMNS (
        CALENDAR ( MIN ( 'Revenue'[Booking date] ), MAX ( 'Revenue'[Booking date] ) ),
        "_Weekday", WEEKDAY ( [Date], 2 ),
        "_WeekNum", WEEKNUM ( [Date], 2 )
    )
VAR _NowNumber =
    MAXX ( FILTER ( _vtable, [Date] = TODAY () ), [_WeekNum] )
VAR _mindate =
    MINX (
        FILTER (
            _vtable,
            YEAR ( [Date] ) = YEAR ( TODAY () )
                && [_WeekNum] = _NowNumber - _currentValue
        ),
        [Date]
    )
VAR _maxdate =
    MAXX (
        FILTER (
            _vtable,
            YEAR ( [Date] ) = YEAR ( TODAY () )
                && [_WeekNum] = _NowNumber - _currentValue
        ),
        [Date]
    )
RETURN
    CALCULATE (
        SUM ( Revenue[Revenue] ),
        FILTER (
            ALLSELECTED ( Revenue ),
            'Revenue'[Booking date]
                >= DATE ( YEAR ( _mindate ) - 1, MONTH ( _mindate ), DAY ( _mindate ) )
                && 'Revenue'[Booking date]
                    <= DATE ( YEAR ( _maxdate ) - 1, MONTH ( _maxdate ), DAY ( _maxdate ) )
        )
    )
2024_target =
VAR _currentValue =
    SELECTEDVALUE ( 'Table 2'[Value] )
VAR _vtable =
    ADDCOLUMNS (
        CALENDAR ( MIN ( 'Revenue'[Booking date] ), MAX ( 'Revenue'[Booking date] ) ),
        "_Weekday", WEEKDAY ( [Date], 2 ),
        "_WeekNum", WEEKNUM ( [Date], 2 )
    )
VAR _NowNumber =
    MAXX ( FILTER ( _vtable, [Date] = TODAY () ), [_WeekNum] )
VAR _mindate =
    MINX (
        FILTER (
            _vtable,
            YEAR ( [Date] ) = YEAR ( TODAY () )
                && [_WeekNum] = _NowNumber - _currentValue
        ),
        [Date]
    )
VAR _maxdate =
    MAXX (
        FILTER (
            _vtable,
            YEAR ( [Date] ) = YEAR ( TODAY () )
                && [_WeekNum] = _NowNumber - _currentValue
        ),
        [Date]
    )
RETURN
    CALCULATE (
        SUM ( Target[Revenue target] ),
        FILTER (
            ALLSELECTED ( 'Target' ),
            'Target'[Booking date] >= _mindate
                && 'Target'[Booking date] <= _maxdate
        )
    )

The result is as follow:

vzhengdxumsft_5-1723180579107.png

 

 

Best Regards

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.