Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
I am currently working a dashboard for an institution that has three different terms per year. They’d like to compare their actual progress to the past term (-1) and to the correspondent to the past year (-3), however when comparing to the past term, week numbers don’t match. For example:
And I’d like to achieve this (This I’ve achieved it by using a lookup table so that I can match the weeks from the past term to this one):
However, my question is if this is achievable from the original date table without the need to use an additional look up table, if this would be the best practice, and how could it be done?
I’d appreciate any help.
Solved! Go to Solution.
Hi @Nuuk ,
I suggest you to create a DimWeekandTerm table to help your calculation.
DimWeekandTerm =
GENERATE(VALUES('Table'[Week Number]),VALUES('Table'[Term]))
Term Sort =
RANKX(DimWeekandTerm,'DimWeekandTerm'[Term],,ASC,Dense)
Measure:
Measure =
VAR _CURRENTTERM =
MAXX ( ALL ( 'DimWeekandTerm' ), 'DimWeekandTerm'[Term Sort] )
VAR _PART1 =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALL ( 'Table' ),
'Table'[Week Number]
= MAX ( DimWeekandTerm[Week Number] ) - 16
&& 'Table'[Term] = MAX ( DimWeekandTerm[Term] )
)
)
VAR _PART2 =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALL ( 'Table' ),
'Table'[Week Number] = MAX ( DimWeekandTerm[Week Number] )
&& 'Table'[Term] = MAX ( DimWeekandTerm[Term] )
)
)
VAR _TermStart =
CALCULATE (
MIN ( DimWeekandTerm[Week Number] ),
FILTER (
ALL ( DimWeekandTerm ),
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALL ( 'Table' ),
'Table'[Week Number] = EARLIER ( DimWeekandTerm[Week Number] )
&& 'Table'[Term] = EARLIER ( DimWeekandTerm[Term] )
)
)
<> BLANK ()
&& DimWeekandTerm[Term Sort] = _CURRENTTERM
)
)
RETURN
IF (
MAX ( DimWeekandTerm[Week Number] ) >= _TermStart,
IF (
MAX ( DimWeekandTerm[Term Sort] )
IN {
_CURRENTTERM - 1,
_CURRENTTERM - 3
},
_PART1,
_PART2
)
)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Nuuk ,
I suggest you to create a DimWeekandTerm table to help your calculation.
DimWeekandTerm =
GENERATE(VALUES('Table'[Week Number]),VALUES('Table'[Term]))
Term Sort =
RANKX(DimWeekandTerm,'DimWeekandTerm'[Term],,ASC,Dense)
Measure:
Measure =
VAR _CURRENTTERM =
MAXX ( ALL ( 'DimWeekandTerm' ), 'DimWeekandTerm'[Term Sort] )
VAR _PART1 =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALL ( 'Table' ),
'Table'[Week Number]
= MAX ( DimWeekandTerm[Week Number] ) - 16
&& 'Table'[Term] = MAX ( DimWeekandTerm[Term] )
)
)
VAR _PART2 =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALL ( 'Table' ),
'Table'[Week Number] = MAX ( DimWeekandTerm[Week Number] )
&& 'Table'[Term] = MAX ( DimWeekandTerm[Term] )
)
)
VAR _TermStart =
CALCULATE (
MIN ( DimWeekandTerm[Week Number] ),
FILTER (
ALL ( DimWeekandTerm ),
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALL ( 'Table' ),
'Table'[Week Number] = EARLIER ( DimWeekandTerm[Week Number] )
&& 'Table'[Term] = EARLIER ( DimWeekandTerm[Term] )
)
)
<> BLANK ()
&& DimWeekandTerm[Term Sort] = _CURRENTTERM
)
)
RETURN
IF (
MAX ( DimWeekandTerm[Week Number] ) >= _TermStart,
IF (
MAX ( DimWeekandTerm[Term Sort] )
IN {
_CURRENTTERM - 1,
_CURRENTTERM - 3
},
_PART1,
_PART2
)
)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
User | Count |
---|---|
87 | |
84 | |
68 | |
64 | |
63 |
User | Count |
---|---|
208 | |
120 | |
113 | |
79 | |
72 |