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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
TusharGaurav
Helper III
Helper III

How to create a dax measure which is a product of 2 different measure with duplicate dimensions

Hi Experts,

 

I have the following sample data:

Order IdLine IdQuantityUnit Price
123451410
123452311
54321184
54321259
54321270

I need to create Revenue where Revenue = Quantity * Unit Price

 

In case of Unit Price = 0, Revenue will be equal to product of sum of quantity and non zero "Unit Price" for the corresponding "Order Id" and "Line Id".

In my report I need to show only "Order Id" ,"Quantity" and "Revenue", the data should be as below in "Table" visual:

Order IdQuantityRevenue
12345773
5432120140

Calculation needed for  "Order Id": 12345 = (4*10) +(3*11)= 73

Calculation needed for  "Order Id": 54321 = (8*4) +((5+7)*9)= 140

Here for "Order Id": 54321, as shown above,Revenue will be equal to product of sum of quantity and non zero "Unit Price" for the corresponding "Line Id".

Can you please suggest how we can achieve this requirement.

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @TusharGaurav - create a DAX measure that handles the logic to sum quantities and apply the non-zero unit price when necessary.

you can replace with your table name:

TotalQuantity =
SUM('sdm'[Quantity])
 
create revenue measure as below:
Revenue =
SUMX(
    SUMMARIZE(
        'SDM',
        'SDM'[Order Id],
        'SDM'[Line Id],
        "RevenueForLine",
        IF(
            MAX('SDM'[Unit Price]) = 0,
            SUM('SDM'[Quantity]) * CALCULATE(MAX('SDM'[Unit Price]), 'SDM'[Unit Price] > 0),
            SUM('SDM'[Quantity]) * MAX('SDM'[Unit Price])
        )
    ),
    [RevenueForLine]
)

 

Ouput:

rajendraongole1_0-1726503805042.png

 

Hope this works

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

2 REPLIES 2
rajendraongole1
Super User
Super User

Hi @TusharGaurav - create a DAX measure that handles the logic to sum quantities and apply the non-zero unit price when necessary.

you can replace with your table name:

TotalQuantity =
SUM('sdm'[Quantity])
 
create revenue measure as below:
Revenue =
SUMX(
    SUMMARIZE(
        'SDM',
        'SDM'[Order Id],
        'SDM'[Line Id],
        "RevenueForLine",
        IF(
            MAX('SDM'[Unit Price]) = 0,
            SUM('SDM'[Quantity]) * CALCULATE(MAX('SDM'[Unit Price]), 'SDM'[Unit Price] > 0),
            SUM('SDM'[Quantity]) * MAX('SDM'[Unit Price])
        )
    ),
    [RevenueForLine]
)

 

Ouput:

rajendraongole1_0-1726503805042.png

 

Hope this works

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hi Rajendra,

 

Thanks a lot for your help.

It worked 🙂 

 

Thanks and Regards,

Tushar Gaurav

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors