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
Anonymous
Not applicable

Calculate delivery costs based on orders rules

Hi all,

 

I just made an example of my data sheet.

In the first colum is the order number started with order 100

This order contains 2 rules for customer A. First rule 1 product 111111 with product description product 1.

Then its possible to deliver the order or let the customer pick it up at the Store.

After all there is a price for each product. (product 1 = 400,68 and product 5 = 27,50)

 

If the order is delivered and the total price is under the €350 there should be and extra product add to the order called product 99999 delivery charge.

 

Order 100 is delivered but about €350 so it is not needed to add the extra product.

Order 101 is deliverd and under the total price of €350 so the extra product 999999 is added

Order 102 is deliverd and under the total price of €350 so the extra product 999999 should be added but did not happend. 

Order 103 is not deliverd (store) but the price is under €350 but it is not needed to add the extra product 999999 because it is not deliverd.

 

So im looking for a dax formula that can calculate the total price of the order and is using the conditions of 350 and delivery status. 

 

Thanks a lot!

 

OrderRuleCustomerArticle numberDescriptiondelivery/storePriceDelivery cost yes or no
1001A111111Product 1delivery€ 400,68no
1002A555555Product 5delivery€ 27,50no
1011B777777Product 7delivery€ 75yes
1012B131313Product 13delivery€ 66,60yes
1013B232323product 23delivery€ 46,50yes
1014B999999Delivery chargedelivery€ 15yes
1021C444444product 4delivery€ 85,68Yes but forgot to add
1022C555555product 5delivery€ 12,80Yes but forgot to add
1031D111111product 1store€ 64,64no
1032D777777product 7store€ 13,77no
1033D161616product 16store€ 41,28no
3 REPLIES 3
wdx223_Daniel
Super User
Super User

@Anonymous  in a calculated column, this formula works well

=
VAR _OrderTotal =
    SUMX (
        FILTER (
            Table4,
            Table4[Order] = EARLIER ( Table4[Order] )
                && Table4[Article number] <> 999999
        ),
        Table4[Price]
    )
VAR _Charge =
    SUMX (
        FILTER (
            Table4,
            Table4[Order] = EARLIER ( Table4[Order] )
                && Table4[Article number] = 999999
        ),
        Table4[Price]
    )
RETURN
    IF (
        Table4[delivery/store] = "delivery"
            && _OrderTotal < 350,
        IF ( _Charge, "yes", "Yes but forgot to add" ),
        "no"
    )
Greg_Deckler
Super User
Super User

@Anonymous So in the case of "Yes but forgot to add" should the measure add in the 15 Euro charge as part of it's 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...
Anonymous
Not applicable

@Greg_Deckler that could be. But in the future the extra collom will be used to be a filter to see which employees did not charge the extra delivery cost. just to remember them that they need to add it to the order.

 

So when the dax formula is working, I would like to filter every week the orders that did not get the extra delivery cost because employees just forget to add it. 

 

If it is not clear at all just ask me!

 

Thanks.

 

 

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.

Top Solution Authors