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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. 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
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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