Forum Discussion
Calculate with OR/AND/NOT in filter
- 10 years ago
I’ll give an example as below. Assuming we have a table like below.
If we want to get the total sales of China on July, we can use following formula.
SalesFromChina_July = CALCULATE ( SUM ( Table1[Sales] ), FILTER ( Table1, AND ( Table1[Country] = "China", MONTH ( Table1[Date] ) = 7 ) ) )If we want to get the total sales of China and USA on July and August, we can use following formula.
SalesFromChina_OR_USA = CALCULATE ( SUM ( Table1[Sales] ), FILTER ( Table1, OR ( Table1[Country] = "China", Table1[Country] = "USA" ) ) )If we want to get the total sales of India on July and August, we can use following formula.
SalesFromIndia = CALCULATE ( SUM ( Table1[Sales] ), FILTER ( Table1, NOT ( OR ( Table1[Country] = "China", Table1[Country] = "USA" ) ) ) )Best Regards,
Herbert
I’ll give an example as below. Assuming we have a table like below.
If we want to get the total sales of China on July, we can use following formula.
SalesFromChina_July =
CALCULATE (
SUM ( Table1[Sales] ),
FILTER ( Table1, AND ( Table1[Country] = "China", MONTH ( Table1[Date] ) = 7 ) )
)If we want to get the total sales of China and USA on July and August, we can use following formula.
SalesFromChina_OR_USA =
CALCULATE (
SUM ( Table1[Sales] ),
FILTER ( Table1, OR ( Table1[Country] = "China", Table1[Country] = "USA" ) )
)
If we want to get the total sales of India on July and August, we can use following formula.
SalesFromIndia =
CALCULATE (
SUM ( Table1[Sales] ),
FILTER (
Table1,
NOT (
OR ( Table1[Country] = "China", Table1[Country] = "USA" )
)
)
)Best Regards,
Herbert
- jesuisbenjamin10 years ago
Advocate I
Thanks. This is very clear.
- Zowie-Thurlow6 years agoFrequent Visitor
This is very useful. However, I am trying to apply different targets to different months based on last years totals. So if month is September then add 70% to last years total, if month is October then 80 % to last year etc, then the months after that should be the same as last year. I have looked everywhere and cannot find the logic to do this. Any help would be great
- ukare19963 years ago
Helper I
Hi, can someone please help me understand why my query is not working as it should be? I am trying to Count number of rows where the field is not equal to "None" and Blanks are not counted in. The query below seems to only take into account one of the filters.Monitor 1 - Action taken by customer =CALCULATE(COUNT('Network protection '[Monitor 1 - Action taken by customer]),FILTER('Network protection ', OR('Network protection'[Monitor 1 - Action taken by customer] <> "None", NOT(ISBLANK('Network protection' [Monitor 1 - Action taken by customer])))))