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
Thanks. This is very clear.