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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
stino123
Helper II
Helper II

Value is applied per line item but should be applied to an order

Hi,

 

I extract data from shopify into Power BI. In doing so all my metrics work well except for shipping. In the below image you see shipping is applied to two items for one order. In reality the shipping is 5 total not 10. To compensate for this in dax I sum the shipping and devide it by the line items. However if a specific item is ordered twice this formula fails. Is there a way in dax or calculated column to have shipping only applied once per order. Rather than per line item. 

 

unnamed (1).png

 

Thanks in advance,

 

1 ACCEPTED SOLUTION
ReneMoawad
Resolver III
Resolver III

Create a New Column with the below formula

Shipping Cost per Line =
Var ShippingID = ShippingTable[ShippingID]
Var nbrOfLines = CALCULATE(
    COUNT(ShippingTable[ShippingID])
    , ALL(ShippingTable)
    , ShippingTable[ShippingID] = ShippingID
)
RETURN
DIVIDE(ShippingTable[Shipping] , nbrOfLines)

View solution in original post

3 REPLIES 3
ReneMoawad
Resolver III
Resolver III

Create a New Column with the below formula

Shipping Cost per Line =
Var ShippingID = ShippingTable[ShippingID]
Var nbrOfLines = CALCULATE(
    COUNT(ShippingTable[ShippingID])
    , ALL(ShippingTable)
    , ShippingTable[ShippingID] = ShippingID
)
RETURN
DIVIDE(ShippingTable[Shipping] , nbrOfLines)

Hey @ReneMoawad this seemed to have worked! Thanks so much!

ryan_mayu
Super User
Super User

 Is there any way to distinguish betweendistinguish between these two scenarios?

could you pls paste the sample data ane expected output?

 

@stino123





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

Proud to be a Super User!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.