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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Years slicer includes data from the selected year's previous year.

Hi 

I have a dynamic slicer which: 

- displays the last 3 years ( does not include the current year). I use a Date table and use the years for the slicer. So for 2021 year the slicer will display 2020,2019,2018

- filters a fact table that include the orginal and revise data. 

 Sample table below: 

 

Assesment yearOrganisation Lodged/Revision

Date

(report was lodged)

Reported number 
2019Company 1Lodged 15/ Jan/ 20205,000
2019Company 1Revision 5/Jan/20216,000
2020Company 1Lodged 15/Jan/202110,000

 

Annual reporting and revision rules: 

- Companies submit their annual report for an assessment year every 15 January on the  following year. For example, for the 2019 assessment year, they must submit their report by 15 Jan 2020. 

- Revisions on their reported number can be made within 12 months after they lodged their orginal report. 

 

Relationship: 

Date table[Dates] is connected to the Fact table[Dates] with one to many relationship. 

 

Problem: 

When I choose an assessment year (For example. 2020) my table also shows revisions from the previous assessment year. (I think its because its filtering using the [Dates] column instead of the [Years] column). Please help. 

 

My pobix file contains a lot of sensitve data so my apologies if I can't attach it here. 

 

Thank you.

Jen 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @Anonymous,

You can break the relation from the date table and use year fields as the source of the slicer, then you can write a measure to extract and compare the field value from the slicer and current row context and use it on the table visual 'visual level filter' to filter records.

Mfilter = 
VAR selected =
    MAX ( Dates[Year] )
RETURN
    IF ( MAX ( Table1[Assessment year ] ) = selected, 1, 0 )

2.png

1.png
Regards,

Xiaoxin Sheng

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi Xiaoxin, 

Thanks for your reply. I've already set up an unconnected date table and using it as a slicer. And it is working as intended in terms of displaying the last 3 years (current year not included). What I'm having trouble is when I choose a year, I aside from getting values for 2020 assessment year, I'm also getting values for 2019. 

Below is how I set up the relationships for my slicer, 

relationship.JPG

The values from the slicer is from the 'Date previous' Table, including the 'Count PY' whic filters the last 3 years. 

slicer.JPG

Also, just want to note that I'm new to PowerBi so I really appreciate your help. 

 

Regards

Jen 

 

 

Anonymous
Not applicable

Hi @Anonymous,

Can you please share a pbix or some dummy data that keep raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Notice: Please do not attach any sensitive data in the sample.

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Hi Xiaoxin, below are the links to the sample data files. 

 

Thanks

 

dummy pbix file 

dummy xlsx file 

Anonymous
Not applicable

HI @Anonymous,

You can break the relation from the date table and use year fields as the source of the slicer, then you can write a measure to extract and compare the field value from the slicer and current row context and use it on the table visual 'visual level filter' to filter records.

Mfilter = 
VAR selected =
    MAX ( Dates[Year] )
RETURN
    IF ( MAX ( Table1[Assessment year ] ) = selected, 1, 0 )

2.png

1.png
Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Sorry, I forgot to ask.  The Mfilter work great if you have one tabl/query but how about if you want to filter multiple tables /query with the same year slicer?

 

This might be an easy fix but I'm new to PowerBI and still learning DAX. Your help will very much appreciated 🙂 

 

Thank you

Jen

Anonymous
Not applicable

 This works. Thank you so much! 🙂 

 

Jen 

Anonymous
Not applicable

Hi @Anonymous,

According to your description, it sounds like you want to achieve a custom filter effect.
For this scenario, I'd like to suggest you create an unconnected date table and use it as the source of slicer. Then you can write a measure to extract the selection and compare it with the fact table date to filter records.

Applying a measure filter in Power BI - SQLBI

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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