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
alexyap
Regular Visitor

DAX for Summation the Multiplication result of each type separately

RAW DATA

 image.png

 

Data Formulation Breakdown

image.png

 

 

EXPECTED RESULT

image.png

 

 

Dear All,

 

I have the RAW data as shown above. I'm trying to create a new measure by using DAX.

 

Basically I have both distinct types "BUY" and "SELL" for the CCY "EURUSD" and I'm trying to calculate the BUY Average price and SELL Average price. However, I always have the problem that Power BI will aggregate them regardless is "BUY" or "SELL" type.

 

I also have provided the expected final result that I hope to achieve.

 

Hoping that someone can shed some light on how should I formulate the DAX for the above.

 

 

Regards,

Alex

 

 

1 ACCEPTED SOLUTION
sdjensen
Solution Sage
Solution Sage

As long as you always filter your result by either having TYPE in your visual or as a filter it should be 2 fairly basic calculations.

 

Notional Value = SUMX(Tabel1, Tabel1[PRICE] * Tabel1[VOLUME] )

Avg Px = DIVIDE([Notional Value], SUM(Tabel1[VOLUME]))

 

 AvgPx.png

edit: I know it doesn't make sence to have PRICE in the table.

/sdjensen

View solution in original post

2 REPLIES 2
sdjensen
Solution Sage
Solution Sage

As long as you always filter your result by either having TYPE in your visual or as a filter it should be 2 fairly basic calculations.

 

Notional Value = SUMX(Tabel1, Tabel1[PRICE] * Tabel1[VOLUME] )

Avg Px = DIVIDE([Notional Value], SUM(Tabel1[VOLUME]))

 

 AvgPx.png

edit: I know it doesn't make sence to have PRICE in the table.

/sdjensen
Greg_Deckler
Super User
Super User

You could create a calculated column or measure:

 

MyCalc = IF([TYPE]="BUY",CALCULATE(),CALCULATE())

Basically, if tye [TYPE] is "BUY", do one calculation, otherwise, do a different calculation.


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