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
Conics
Frequent Visitor

Struggling with formula: select all rows, excluding date slicers

Hi,

I'm currently struggling with a formula. so here we go:

This is a photo of my dataset:

Knipsel.PNG

Actual excal attached below on the dropbox link.

This means I have an order ORD001 for Art. A with a delivered qty of 5 pcs on line 10 and in the same order a canceled line 20 for 5 pieces of Art. B ordered, but since it has been canceled, none were delivered.

 

I need to calculate the service level of deliveries:
ORD001- Art. A: 5 out of 5 delivered on 01/03 would mean 100% on a line level;
ORD001- ART. B: 0 out of 5 = 0% and
ORD001-Art. C: 10 out of 10 on 05/03/2022 would be 100% on line level.
while on total ORDER level, that would be 15 delievred out of 20, so 75%.

I also show another order ORD004 with 20 out of 20 delivered pieces for article B, and 0 out of 40 deliverted for ART. B.

That would mean, for Article A 100% service level, for Article B 0%, for the complete order 20 out of 60 delivered = 33%

 

Now for the tricky part:

We want to use a date slicer (Based on delivery date). This will filter out all rows with that Date, BUT... I really need to take in account the date-less rows as well (where cancellations have been happening).


So when looking back at ORD001:
My service level on 01/03 would be:  total ordered 20pieces, delivered: 5 pieces, service level 5 out of 20 = 25%
My Service level on 05/03 would be: total ordered 20pieces, delivered:15 pieces, service level 15 out of 20 = 75%.


The issue is now: how do I calulate the total Ordered, in such a way, that IT ONLY counts the QTY canceled for the orders applied in the date filter. In other words, If I select 01/03/2022, it should look for all orders with a delivery on that date, then calculate lines delivered AND Qty Canceled (for these orders only), and summarize these.

Link to my Dataset and PBIX file

In my file you will see that no matter how much I change the date slicer, the Total Canceled remains the same... so there's some error in my calculated "total ordered"

2 REPLIES 2
Anonymous
Not applicable

Hi @Conics ,

 

You need a helper column to tell where the order is when the date is empty.

Add a new index column in Power Query Editor.

vcgaomsft_0-1648804685990.png

vcgaomsft_1-1648805649754.png

Modify the measure.

Total Applied Cancelled Lines = 
VAR _mindate =CALCULATE(MIN('Blad1'[Index]),FILTER('Blad1','Blad1'[Delivery Date]=MIN('Blad1'[Delivery Date])))
VAR _maxdate =CALCULATE(MAX('Blad1'[Index]),FILTER('Blad1','Blad1'[Delivery Date]=MAX('Blad1'[Delivery Date])))
VAR _value =
CALCULATE (
    [QTY ordered],
    FILTER (
        'Blad1',
        Blad1[Cancelled] = "Yes"
            && ISBLANK ( Blad1[Delivery Date] ) = TRUE()
            &&'Blad1'[Index]>=_mindate
            &&'Blad1'[Index]<=_maxdate
    )
)
RETURN
SWITCH(
    TRUE(),
    _value<>0,_value,0)

Filter index columns can help formulas determine whether they are within or outside of this time period.

vcgaomsft_2-1648805817251.png

vcgaomsft_3-1648805902850.png

The result is 5.

vcgaomsft_4-1648806006004.png

 

Attach the PBIX file for reference. Hope it helps.

 

Best Regards,
Community Support Team_Gao

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems with it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

@Anonymous: when moving the slicer dates to 01/04/2022 (both of them) I see ZERO, while I was expecting 40 cancelled?

Helpful resources

Announcements
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