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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Chari
Frequent Visitor

How to compare the values based on the user's selected year Vs previous year.

Hello All....
I have a date table and sales tables; in the sales table, I have 3 columns: WL, date, and amount.

Requirement:
if we select any year from year dropdown, it should compare with previous year

Ex1: If we choose 2024, the comparison should be 2024 vs. 2023, and it should show by quarterly.
Ex2: If we select 2020, the comparison should be 2020 against 2019, and it should show by quarterly.

The table should show like below.

Chari_0-1732029179051.png

----------------------------------------------------------------------
I created below measures

Previous = var _s = SELECTEDVALUE (Date[tDate]. [Year])
RETURN
CALCULATE(SUM(Sales[Amount]),FILTER(Sales,YEAR([Date])=_s))

Previous = var _s = SELECTEDVALUE(Date[tDate]. [Year]) -1
RETURN
CALCULATE(SUM(Sales[Amount]),FILTER(Sales,YEAR([Date])=_s))


O/P with the above measures.
For select year (2023), the previous column is coming as blank, and the previous year (2022) current column is coming as blank.

For quarters, we have to go with the drill throw option. Without drillthrough, is there any other option?

Chari_1-1732030035382.png

I tried with field parameters also, but o/p is the same.

Parameter = {
("Current", NAMEOF('Measure'[Current]), 0),
("Previous", NAMEOF('Measure'[Previous]), 1)
}

 

 





1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Chari 

 

Try changing your Previous measure using the time-intelligence function SAMEPERIODLASTYEAR() like this:

Previous = CALCULATE(
    SUM(SalesTable[Amount]),
    SAMEPERIODLASTYEAR(DateTable[Date])
)

Current measure:

Current = CALCULATE(
    SUM(SalesTable[Amount]),
    YEAR(SalesTable[Date]) = SELECTEDVALUE(DateTable[Year])
)

 

vxianjtanmsft_0-1732068744620.png

 

Best Regards,
Jarvis Tang
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

2 REPLIES 2
Anonymous
Not applicable

Hi @Chari 

 

Try changing your Previous measure using the time-intelligence function SAMEPERIODLASTYEAR() like this:

Previous = CALCULATE(
    SUM(SalesTable[Amount]),
    SAMEPERIODLASTYEAR(DateTable[Date])
)

Current measure:

Current = CALCULATE(
    SUM(SalesTable[Amount]),
    YEAR(SalesTable[Date]) = SELECTEDVALUE(DateTable[Year])
)

 

vxianjtanmsft_0-1732068744620.png

 

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

 

Anonymous
Not applicable

Hi @Chari 

 

Sorry to bother you.

I would like ask if my previous reply has helped you resolved the problem? If so, please consider accepting the previous reply as a solution. This will make it easier for other users experiencing the same problem to find a solution.

If you have any other questions, please feel free to contact me.

 

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

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.