Forum Discussion
Need guidance
Hello all ,
Please give me some guidence on how to get previous year month dates.
i have a date table with Rank like below
If I select 12/3/2022, the result should be rank 1
If I select 12/31/2022 then the result should be Rank 2 and Rank 1 of previous years since rank 2 is not available in previous years.
ex:
| Dec | Dec-20 | 12/5/2020 | 1 |
| Dec | Dec-21 | 12/4/2021 | 1 |
| Dec | Dec-22 | 12/31/2022 | 2 |
TIA
- Anonymous3 years ago
Hi Puja ,
Please refer to my pbix file.
Measure = VAR _1 = SELECTEDVALUE ( data[Date] ) VAR _format = FORMAT ( _1, "MMM" ) VAR _YEAR = YEAR ( _1 ) RETURN IF ( _1 = SELECTEDVALUE ( 'Table'[Date] ), 1, IF ( _format = SELECTEDVALUE ( 'Table'[ Month] ) && _YEAR <> SELECTEDVALUE ( 'Table'[year_colun] ), 1 ) )How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ PollyIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- andhiii079845Solution Sage
I do not understand your filter logic. Do you want to compare your current seleted month with the privious year (same month)?
Also I need some data example no screenshot. If rank is calculated also the DAX definition.- PujaHelper III
The goal is compare current year Date with previous year Date (not Month vs Month)
As the dates are not consistent , I added rank (this is optional )
Here is the test DATA. The eamples were added in my first request.Date Month Year Rank 8/14/2021 Aug Aug-21 1 8/28/2021 Aug Aug-21 2 8/20/2022 Aug Aug-22 1 12/5/2020 Dec Dec-20 1 12/4/2021 Dec Dec-21 1 12/3/2022 Dec Dec-22 1 12/31/2022 Dec Dec-22 2
- AnonymousNot applicable
Hi Puja ,
Please refer to my pbix file.
Measure = VAR _1 = SELECTEDVALUE ( data[Date] ) VAR _format = FORMAT ( _1, "MMM" ) VAR _YEAR = YEAR ( _1 ) RETURN IF ( _1 = SELECTEDVALUE ( 'Table'[Date] ), 1, IF ( _format = SELECTEDVALUE ( 'Table'[ Month] ) && _YEAR <> SELECTEDVALUE ( 'Table'[year_colun] ), 1 ) )How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ PollyIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- PujaHelper III
Hi Anonymous ,
Thank you for your time. Your solution working for some dates only. In this example if user choose 12/4/2021, then same date and previous year date.
Another example.
Much appriciated for your help