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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors