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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Saurabh_Gora
Regular Visitor

How can I create YOY calculations when I have separate rows for YTD and LYTD?

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 PeriodAmount
YTD1200
LTYD1000
Rolling 12 month CY800
Rolling 12 months PY900
  
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.
1 REPLY 1
PaulDBrown
Community Champion
Community Champion

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
        )
)

Dp.pngmodel.png

Again for simplicity purposes, add an order column to the fact table:

fact table.png

 

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:

result.png

I've attached the sample PBIX file

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






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
Top Kudoed Authors