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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Matt_Gol
Helper I
Helper I

How to multiply two columns from two different tables(Direct query)

Hi everyone

I have a report in direct query.

Consider I have 2 tables(table1 and table2) which both have a column that contains stock items. The relation is one to many.

how can I calculate Table1[Qty]*Table2[Price] for each Stock item? (I did it by creating a measure but when I use Card, the filters doesn't apply on it , but in a table, it works perfect)

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Matt_Gol , As suggested by @Luuky  Try SUMX with related. If there is 1-M relationship between Table 2 to table 1 it should work

 

example

Sumx(Table1, Table1[Qty]*related(Table2[Price]))

 

if not then you might have do more work

 

example

 

Sumx(Table1, Table1[Qty]*Maxx(filter(Table2, Table[Item] = Table2[Item]) , Table2[Price]))

 

you can more conditions in second one as per need

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
Matt_Gol
Helper I
Helper I

Thank you guys, it works. Much appreciated for your help

@amitchandak @Luuky 

amitchandak
Super User
Super User

@Matt_Gol , As suggested by @Luuky  Try SUMX with related. If there is 1-M relationship between Table 2 to table 1 it should work

 

example

Sumx(Table1, Table1[Qty]*related(Table2[Price]))

 

if not then you might have do more work

 

example

 

Sumx(Table1, Table1[Qty]*Maxx(filter(Table2, Table[Item] = Table2[Item]) , Table2[Price]))

 

you can more conditions in second one as per need

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Luuky
Helper I
Helper I

Hi @Matt_Gol ,

Try Sumx for it in a measure. If thats not working then I need some visualisation of the tables and how they are related.

Greetings,

Luuk

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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