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

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

 

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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? 

 

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

 

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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
avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)