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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

How to display/filter row tables between 2 years dynamically

Hi,

 

I was wondering if there's a way where I can filter out my table results based on two years. My table A has date column and many miscellaneous columns. So currently I would like the table A to display January 2018 (or 1/1/2018) and December 2019 (or 12/31/2019) information. However, once January 1st, 2020 appears, I would like my table A to display row results between January 2019 and December 2020. Is there a way I can do so? Maybe in DAX or clicking some filter option? Could someone show me? I'm still fairly new to PowerBI.

 

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Yeah I solved it. I used a workaround where I isolated the year in the date and made a new column after it. Then I used DAX to indicate whether the years were between the 2 years I wanted the results to be using "yes" and "no". If they weren't, I wouldn't display them using the DATA table, and unticking the "no" rows. That would then allow my report to not display answers that are between 2 years I would like.

 

In addition, I meant that currently I wanted my results to show data between 1/1/18 and 12/31/19. When it comes to 1/1/20, I would like my data to show 1/1/19 and 12/31/20 data. I think my solution does that. That way, my results are dynamic and I wouldn't have to go through steps on fixing the data every new year.

View solution in original post

3 REPLIES 3
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

 

Have you solved your problem?

 

If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

 

If you still need help, please share some data sample and your desired output. 

 

In addition, I have a little confused about your scenario. What's mean of once January 1st, 2020 appears?

 

Best Regards,

Cherry

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

Yeah I solved it. I used a workaround where I isolated the year in the date and made a new column after it. Then I used DAX to indicate whether the years were between the 2 years I wanted the results to be using "yes" and "no". If they weren't, I wouldn't display them using the DATA table, and unticking the "no" rows. That would then allow my report to not display answers that are between 2 years I would like.

 

In addition, I meant that currently I wanted my results to show data between 1/1/18 and 12/31/19. When it comes to 1/1/20, I would like my data to show 1/1/19 and 12/31/20 data. I think my solution does that. That way, my results are dynamic and I wouldn't have to go through steps on fixing the data every new year.

jdbuchanan71
Super User
Super User

Create a Dates table by going to the Modeling tab, clicking 'New Table' and entering the following formula.

Dates = CALENDAR( DATE (2016, 1, 1), DATE ( YEAR ( TODAY() ), 12, 31) )

You can change the starting year if you want but make sure it covers your whole data set.

 

Next add a couple of calculated columns to the Dates table.

 

Year = YEAR ( Dates[Date] )
Year Offset = YEAR ( Dates[Date] ) - YEAR ( TODAY() )

You can add more like quarter, month name etc.  We just need the Year Offset for what you are trying to do.

 

Join the Dates table to your data table.

 

Now, in your visual put a filter on it for year offset and select 0 and -1.  Because the Year Offset uses TODAY() it will recalc when the model is refreshed so on 1/1/2020 [Year Offset] = 0 and -1 will give you the years 2020 and 2019.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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