Forum Discussion

admin_xlsior's avatar
admin_xlsior
Post Prodigy
5 years ago
Solved

Calculate issue, something wrong with the context ?

Hi guys,

 

Needs some light on of my measure.

I have this table :

 

And the last column is a measure which is like this :

Count open critical orders = CALCULATE(
                                        DISTINCTCOUNTNOBLANK('Work orders'[Work order number]),
                                        'Work orders'[Critical] = "Yes",
                                        NOT('Work orders'[Status] IN {"Closed", "Invoiced", "Finished", "Canceled"})
)

 

 

Issue is why if I list down by All the status, it won't filtered correctly ?

 
 

Is there any context issue in this case ? it looks like the calculate, after it is being filtered, it won't take a look at other statuses. When I list down all the status, at least it would give me 0 (zero), right for other status that excluded in my filter.

 

Thanks

 

  • admin_xlsior , My Bad, change it like

     

    Count open critical orders = CALCULATE(
    DISTINCTCOUNTNOBLANK('Work orders'[Work order number]),
    filter('Work orders','Work orders'[Critical] = "Yes" &&
    NOT('Work orders'[Status] IN {"Closed", "Invoiced", "Finished", "Canceled"})
    ))

4 Replies

  • admin_xlsior , Try like

    Count open critical orders = CALCULATE(
    DISTINCTCOUNTNOBLANK('Work orders'[Work order number]),
    filter('Work orders','Work orders'[Critical] = "Yes",
    NOT('Work orders'[Status] IN {"Closed", "Invoiced", "Finished", "Canceled"})
    ))

    • admin_xlsior's avatar
      admin_xlsior
      Post Prodigy

      oo but FILTER, can only contain 1 condition, is it?

      And actually now I'm confuse why we need to use FILTER again, while CALCULATE is able to do filtering, it even support multiple condition, right ? 

       

  • admin_xlsior , My Bad, change it like

     

    Count open critical orders = CALCULATE(
    DISTINCTCOUNTNOBLANK('Work orders'[Work order number]),
    filter('Work orders','Work orders'[Critical] = "Yes" &&
    NOT('Work orders'[Status] IN {"Closed", "Invoiced", "Finished", "Canceled"})
    ))

    • admin_xlsior's avatar
      admin_xlsior
      Post Prodigy

      Hi amitchandak 

       

      ahh yeah.. I'm about to reply the same ğŸ˜€

      I'm using AND function though, but it is the same idea. 

       

      Alhtough I'm still not too convince why I need to use FILTER, I thought CALCULATE will do the same.

       

      Thanks amitchandak