cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tsynenkyy
Helper II
Helper II

Filters Compare two years, first one selected, the second one automated

Hi guys,

 

I have the following two filters:

tsynenkyy_0-1665038496906.png

You select both years and the measures works perfectly, but the next step is to automatize the "Year & Month Comparison" so when I select "Year & Month" = 2022   then automatically the filter "Year & Month Comparison" will select 2021.

 

Relationship between both time tables:

tsynenkyy_2-1665038626297.png

thanks

2 REPLIES 2
amitchandak
Super User
Super User

@tsynenkyy , with help from a date table last year can be

 

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))

 

//Only year vs Year, not a level below

This Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))
diff = [This Year]-[Last Year ]
diff % = divide([This Year]-[Last Year ],[Last Year ])

 

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA



!! Microsoft Fabric !!
Microsoft Power BI Learning Resources, 2023 !!
Learn Power BI - Full Course with Dec-2022, with Window, Index, Offset, 100+ Topics !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!

Hi, many thanks for your asnwer but I think this is not what I need, actually I think that what I need is not possible in Power BI.

 

I need to keep the functionality I have (select both years) but when I firstly select the "Year and Month" it must automatically change the value on my other filter "year and month comparison) to YearSelected - 1, but I think is not possible that.

Helpful resources

Announcements
May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Submit your Data Story

Data Stories Gallery

Share your Data Story with the Community in the Data Stories Gallery.

Top Solution Authors