Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
How can I create YOY calculations when I have separate rows for YTD and LYTD. This also has to work with data filter that lets user choose b/w YTD, LYTD ,Rolling 12 months current, Rolling 12 months prior. | |
Data Structure | |
Time Period | Amount |
YTD | 1200 |
LTYD | 1000 |
Rolling 12 month CY | 800 |
Rolling 12 months PY | 900 |
I want to create a KPI with YoY values with a time period filter consisting of above 4 values. Note, we are not getting date level granular data in Power BI and creating these calcuations within SQL itself. |
I'm not too sure what the final visual you need is, but see if this helps.
Firstly, create an independent table with the periods and an order column for simplicity purposes)
Dim Period =
ADDCOLUMNS (
DISTINCT ( FactTable[Time Period] ),
"Order",
SWITCH (
FactTable[Time Period],
"YTD", 1,
"LTYD", 2,
"Rolling 12 month CY", 3,
"Rolling 12 months PY", 4
)
)
Again for simplicity purposes, add an order column to the fact table:
Now create a measure for each metric following this pattern:
YTD =
CALCULATE ( [Sum Amount], FILTER ( ALL ( 'FactTable' ), FactTable[Order] = 1 ) )
and for the comparisons, again for each metric:
YTD vs Selected period =
VAR _SP =
SWITCH (
SELECTEDVALUE ( 'Dim Period'[Order] ),
1, [YTD],
2, [LTYD],
3, [Rolling 12 month CY],
4, [Rolling 12 month PY]
)
RETURN
DIVIDE ( [YTD], _SP )
To get:
I've attached the sample PBIX file
Proud to be a Super User!
Paul on Linkedin.