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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Puja
Helper III
Helper III

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 

 

Puja_0-1677696023150.png

 

If I select 12/3/2022, the result should be rank 1 

 

Puja_1-1677696190047.png

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:

DecDec-2012/5/20201
DecDec-2112/4/2021 1
DecDec-2212/31/2022 2

 

 

 

TIA

 

1 ACCEPTED SOLUTION
Anonymous
Not 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
        )
    )

vpollymsft_0-1679291584346.png

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 _ Polly

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

4 REPLIES 4
Anonymous
Not 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
        )
    )

vpollymsft_0-1679291584346.png

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 _ Polly

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

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.

Puja_1-1679580652925.png

Another example.

Puja_2-1679580886153.png

 

Much appriciated for your help 

 

 

 

 

andhiii079845
Solution Sage
Solution 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. 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@andhiii079845 

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 YearRank
8/14/2021AugAug-211
8/28/2021AugAug-212
8/20/2022AugAug-221
12/5/2020DecDec-201
12/4/2021DecDec-211
12/3/2022DecDec-221
12/31/2022DecDec-222

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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