March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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
Second spreadsheet
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 😊
Solved! Go to Solution.
Hi @Kat2014
Here I create a set of sample:
Revenue Table:
Target Table:
Then add a calculated table:
Table 2 = {1,2,3,4}
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]
)
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:
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.
Hi @Kat2014
Here I create a set of sample:
Revenue Table:
Target Table:
Then add a calculated table:
Table 2 = {1,2,3,4}
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]
)
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:
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.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
89 | |
84 | |
70 | |
51 |
User | Count |
---|---|
206 | |
143 | |
97 | |
79 | |
68 |