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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Need Formula of DAX Calculation for Quantity by Amount

Hello,

 

I have the below data:

QtyAmountTotal
21020
236
144

Total                                30 - Result Expecting in a new measure

I have Qty column in TableA and Amount column in TableB , I was creating a DAX calculation (A New Measure) in TableA where in i should be able to multiply TableA[Qty] * TableB[Amount] 

I am trying to create a DAX caluclation for this where in i will get the total of that calculation as "30" shown in the table and display the total '30' into a CARD visual in Power BI.

 

Solution i tried:

TableANewMeasure = Sum('TableA'[Qty]) * Sum('TableB'[Amount])

 

I am a newbie so was trying to solve this simple issue. Thanks in Advance for your help.

 

Thank You,

TSN

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Anonymous 

According to your description, you want to calculate the sum of the [Quantity] * [Amount]. Right?

Here are the steps you can refer to :

(1)This is my test data:

vyueyunzhmsft_1-1670294644799.png

 

(2)We can click "New measure" and enter this:

*value = var _t = ADDCOLUMNS('Table B' , "Qty" , CALCULATE(SUM('Table A'[Qty])))
return
SUMX(_t ,[Amount]*[Qty])

(3)Then we can put this on the visual and we can meet your need:

vyueyunzhmsft_2-1670294956305.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

10 REPLIES 10
v-yueyunzh-msft
Community Support
Community Support

Hi , @Anonymous 

According to your description, you want to calculate the sum of the [Quantity] * [Amount]. Right?

Here are the steps you can refer to :

(1)This is my test data:

vyueyunzhmsft_1-1670294644799.png

 

(2)We can click "New measure" and enter this:

*value = var _t = ADDCOLUMNS('Table B' , "Qty" , CALCULATE(SUM('Table A'[Qty])))
return
SUMX(_t ,[Amount]*[Qty])

(3)Then we can put this on the visual and we can meet your need:

vyueyunzhmsft_2-1670294956305.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Anonymous
Not applicable

@v-yueyunzh-msft  Thank You, This works! , Marking this as solution to this.

 

Thank You,

tamerj1
Super User
Super User

Hi @Anonymous 

Please try

NewMeasure =
SUMX (
SUMMARIZE (
TableA,
TableB[MatNbr],
TableB[Amount],
"@Qty", SUM ( TableA[Qty] )
),
[Amount] * [@Qty]
)

Anonymous
Not applicable

@tamerj1  This is not working. The Calculation Qty * Amount is coming as incorrect.

tamerj1
Super User
Super User

Hi @Anonymous 

What is the relationship between the two tables?

Anonymous
Not applicable

@tamerj1 

TableB::    1->*      ::TableA

[One - Many Relationship]

 

Thanks TSN,

@Anonymous 

Via which column?

Anonymous
Not applicable

@tamerj1 : Via MatNbr column

 

Thank You,

TSN

Greg_Deckler
Community Champion
Community Champion

@Anonymous First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler , Thanks , Would you be more specific to this problem , As i am trying to calucate quantity * Amount = Total and the sum of that list of total. I saw the post as it is calculated based on the date.

As i am a newbie to this DAX , It would be much appreciated if you can provide a solution specific to my question -

Thanks,

TSN

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.