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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Ema123
New Member

PY column not responding to MTD/QTD/YTD slicer

I'm creating a Power BI dashboard using Zebra BI table visual with two columns: PY (Previous Year) and AC (Actuals). In my database "Baza 23," I have a column "Scenarij" that refers to either 2022 (Previous Year) or 2023 (Actuals).

 

I also have a calendar table and I have made a connection between the calendar table (date column) and "Baza 23" (date column).

I made two measures:

1: AC filter = CALCULATE(SUM('Baza 23'[EUR]), 'Baza 23'[Scenarij] = "2023")

2: PY filter = CALCULATE(SUM('Baza 23'[EUR]), 'Baza 23'[Scenarij] = "2022")

 

When I put these measures in the Zebra BI table, they work perfectly fine. However, I want to put an MTD/QTD/YTD slicer and connect it to these two columns so that when I choose a scenario in this slicer, the data in the PY column and AC column change accordingly. To achieve this, I created a "Selected Period" table with two columns: Period column and Period ID:

 

Capture.PNG

 

 

I added Selected period measure: Selected Period = MIN('Selected Period'[Period ID]). I was able to connect my columns to MTD/QTD/YTD slicer by using these two measures:

 

AC = SWITCH('Selected Period'[Selected Period],

1, CALCULATE([AC filter], DATESMTD('Calendar'[Date])),

2, CALCULATE([AC filter], DATESQTD('Calendar'[Date])),

3, CALCULATE([AC filter], DATESYTD('Calendar'[Date]))

 

PY = SWITCH('Selected Period'[Selected Period],

1, CALCULATE([PY filter], DATESMTD('Calendar'[Date])),

2, CALCULATE([PY filter], DATESQTD('Calendar'[Date])),

3, CALCULATE([PY filter], DATESYTD('Calendar'[Date])))

 

AC measure works perfectly fine, but when I use the PY measure and put it in the Zebra BI table, the column doesn't show any numbers. Why is that and how can I fix this problem?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Ema123 ,

@olgad  gives some direction and reasons on your problem. (@olgad Thanks to for your efforts).

Please try to update the formula of below measures as below and check if they can return the expected result...

AC filter =
VAR _selyear =
    SELECTEDVALUE ( 'Calendar'[Year] )
RETURN
    CALCULATE ( SUM ( 'Baza 23'[EUR] ), 'Baza 23'[Scenarij] = _selyear )
PY filter =
VAR _selyear =
    SELECTEDVALUE ( 'Calendar'[Year] )
RETURN
    CALCULATE (
        SUM ( 'Baza 23'[EUR] ),
        FILTER ( 'Baza 23', 'Baza 23'[Scenarij] = _selyear - 1 ),
        ALL ( 'Baza 23' )
    )

If the above ones can't help you figure out, please provide some raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

 

View solution in original post

3 REPLIES 3
Ema123
New Member

Hi, thank you for your respond. The only other slicer that I am using is "Month" slicer form 'Calendar'[Month]. Is there a way to write these measures in a way they are not hardcoded? 

 

Anonymous
Not applicable

Hi @Ema123 ,

@olgad  gives some direction and reasons on your problem. (@olgad Thanks to for your efforts).

Please try to update the formula of below measures as below and check if they can return the expected result...

AC filter =
VAR _selyear =
    SELECTEDVALUE ( 'Calendar'[Year] )
RETURN
    CALCULATE ( SUM ( 'Baza 23'[EUR] ), 'Baza 23'[Scenarij] = _selyear )
PY filter =
VAR _selyear =
    SELECTEDVALUE ( 'Calendar'[Year] )
RETURN
    CALCULATE (
        SUM ( 'Baza 23'[EUR] ),
        FILTER ( 'Baza 23', 'Baza 23'[Scenarij] = _selyear - 1 ),
        ALL ( 'Baza 23' )
    )

If the above ones can't help you figure out, please provide some raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

 

olgad
Super User
Super User

Hi, on the page itself, are you selecting any years from the calendar slicer/filter? 

You have hardcoded years in your measures, so it might happen some other filters prevent you from seeing the numbers. Can you please give more info?


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.