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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MiguelMercadoS
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
dax
Community Support
Community Support

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

4 REPLIES 4
dax
Community Support
Community Support

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.

Thank you Zoe, it's just what I needed. Best regards

Ashish_Mathur
Super User
Super User

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/
Greg_Deckler
Super User
Super User

@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!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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