cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TSN
Frequent Visitor

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 , @TSN 

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 , @TSN 

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

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

 

Thank You,

tamerj1
Super User
Super User

Hi @TSN 

Please try

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

TSN
Frequent Visitor

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

tamerj1
Super User
Super User

Hi @TSN 

What is the relationship between the two tables?

TSN
Frequent Visitor

@tamerj1 

TableB::    1->*      ::TableA

[One - Many Relationship]

 

Thanks TSN,

@TSN 

Via which column?

TSN
Frequent Visitor

@tamerj1 : Via MatNbr column

 

Thank You,

TSN

Greg_Deckler
Super User
Super User

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


@ 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!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

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

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

BizApps LATAM 2023

Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

Power Platform Bootcamp

Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.

Top Solution Authors
Top Kudoed Authors