Forum Discussion

CastroRibeiro's avatar
4 years ago

Filter two different values based on a column

I have a customer who has a delivery time that is different from the rest of the other customers, for this customer the time is <= 9 while for the rest the time is <= 8

How do I only count customer times for UNBCES when the delivery time is <=9 at the same time I filter the data of other customers which is <=8

 

My attempt was first to count the values of the UNBCES client and then take these values and filter again the other clients that have a shorter time, which is <=8, but it didn't work

 

UNBCES_CLIENT count

 

UNBCES_CLIENT = 
var UNBCES = 
    CALCULATE(
       COUNTROWS(fcriticalDemands),
            FILTER(
                fcriticalDemands,
                fcriticalDemands[CLIENT]="UN-BC" &&
                fcriticalDemands[deliveryTime]<=9))

 return UNBCES    

 

 

UNBCES_CLIENT and trying to count the rest of the clients

 

CLIENTS = 
var CLIENT= 
    CALCULATE(
       Leadtime[UNBCES_CLIENT],
            FILTER(
                fcriticalDemands,
                fcriticalDemands[deliveryTime]<=8))

return CLIENT

 

 

2 Replies

  • Hi CastroRibeiro 

     

    can you share a sample data and let us know how do you like to show the result?

     

    BTW, if you want to count with different values, try this:

     

    Count_CLIENT = 
    Vat _Time = if(fcriticalDemands[CLIENT]="UN-BC",9,8)
    var _Count= 
        CALCULATE(
           COUNTROWS(fcriticalDemands),
                FILTER(
                    fcriticalDemands,
                    fcriticalDemands[deliveryTime]<=_Time))
    
     return 
     _Count

     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

    Appreciate your Kudos!!

     

    • CastroRibeiro's avatar
      CastroRibeiro
      Helper I

      I want to show something like this, but I have to calculate it differently for the UN-BC client and for the others it's the same thing

       

      The other colors refer to other time calculations, the green value is what we think of the ideal time, which for the un-bc client is <=9