Nested filter throws error but can't understand why

Viewed 30

Below measure throws me an error, but can't understand why, or how I could solve the issue. If someone could explain it to me that'd be great !

CALCULATE (
  SUM(BASE_SALES[VOLUME]),
  FILTER(
    BASE_SALES,
    BASE_SALES[STORE] IN FILTER(STATES, STATES[STATE] = "Cleveland")
  )
)

error message (is French):

Le nombre d'arguments n'est pas valide. La fonction CONTAINSROW doit avoir une valeur pour chaque colonne de l'expression de table.

1 Answers

This is the reason for error BASE_SALES[STORE] IN FILTER(STATES, STATES[STATE] = "Cleveland") - When you use IN it should be a list of Values not a table. For example:

BASE_SALES[STORE] IN CALCULATETABLE(VALUES(STATES[STORE]), STATES[STATE] = "Cleveland")

I'm not sure about your aim but try this if tables are linked

CALCULATE (
  SUM(BASE_SALES[VOLUME])
  ,STATES[STATE] = "Cleveland"
)

If they are not linked then try this :

CALCULATE (
  SUM(BASE_SALES[VOLUME])
  ,TREATAS(
     CALCULATETABLE(VALUES(STATES[STORE]),STATES[STATE] = "Cleveland")
     ,BASE_SALES[STORE]
  )
)
Related