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
feyd
Frequent Visitor

Calculate value difference from column of a same table with hierarchy from another table

Hi everyone,

 

I have to calculate value difference between rows of the same column in one table where "File Name" column from "Database" table has "File for comparison" file from "DIM_File" table. I've tried with USERELATIONSHIP and it worked, but I was unable to filter the result by "Group".

 

What I'm trying to get -> Difference=sum(F2[Amount])-sum(A1[Amount])

or visually

GroupProdcut CodeAmount F2Amount A1Difference
X1001900190
Y2005013080

 

 

Model looks like thisModel looks like this

Database table sample:

File NameDateProduct CodeAmount
A11.jan.2018.20050
A11.jan.2018.1000
A11.feb.2018.20080
F21.jan.2018.20050
F21.jan.2018.100100
F21.feb.2018.2000
F21.feb.2018.10090
B11.jan.2017.200110
B11.jan.2017.100100
B11.feb.2017.20080
B11.feb.2017.10090

 

DIM_File table sample:

File NameYearFile for comparisonFile type
A12018 A
F22018A1A
B12017 B

 

DIM_Product table sample:

Product CodeGroup codeName
2001Prod1
1002Prod2
3001Prod3

 

DIM_Group table sample:

Group codeGroup
1X
2Y

 

Thanks!

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

I would look at the LOOKUPVALUE function in DAX. https://docs.microsoft.com/en-us/dax/lookupvalue-function-dax

 

 


@ 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...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

I would look at the LOOKUPVALUE function in DAX. https://docs.microsoft.com/en-us/dax/lookupvalue-function-dax

 

 


@ 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...

Worked like a charm 🙂

 

Thanks!

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.