Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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
Solved! Go to Solution.
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.
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
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.
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.
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
65 |
User | Count |
---|---|
136 | |
118 | |
101 | |
71 | |
61 |