cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

Compare years values by filter

Hello everyone

 

I need to compare values by filter, for example 

 

I have in 2019 a expenses for 15000000 

for 2018 expenses for 20000000

for 2017 35000000

and for 2016 45000000

 

if i filter two years, for example 2019 and 2018 i need to calculate the diference wich is 500000 but if i would like to compare 2018 and 2017 the value would be 15000000 and the same if i need to compare values by the year filtered. 

 

I have this in Tableau wich works: 

ZN(SUM([-Ing Directos])) - LOOKUP(ZN(SUM([-Ing Directos])), -1)
 
But I don't know how to do that in power bi, can yopu please help me? thank you in advance!
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Compare years values by filter

Hi @MiguelMercadoS , 

You could refer to my sample for details.

796.PNG

Best Regards,
Zoe Zhi

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

3 REPLIES 3
Highlighted
Super User IX
Super User IX

Re: Compare years values by filter

@MiguelMercadoS - Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




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

Proud to be a Super User!




Highlighted
Super User V
Super User V

Re: Compare years values by filter

Hi,

Create a Calendar Table with Year as a calculated column.  Build a relationship from the Date column of your source data table to the date column of yoru Calendar Table.  In your slicer, drag Year from the Calendar Table and select any 2 years.  Write these measures:

Total = SUM([-Ing Directos])

Total in last selected year = calculate([Total],datesbetween(Calendar[Date],edate(max(calendar[Date]),-12)+1,max(calendar[Date])))

Total in last selected year = calculate([Total],datesbetween(Calendar[Date],min(calendar[Date]),edate(min(calendar[Date]),12)-1))

Difference = [Total in last selected year]-[Total in last selected year]

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Highlighted
Community Support
Community Support

Re: Compare years values by filter

Hi @MiguelMercadoS , 

You could refer to my sample for details.

796.PNG

Best Regards,
Zoe Zhi

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

Helpful resources

Announcements

August Community Highlights

Check out a full recap of the month!

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

Top Solution Authors