Forum Discussion

gvg's avatar
gvg
Post Prodigy
4 years ago
Solved

Help with IN

Hi folks,

 

Maybe someone could help me out in the following situation. I know that I can calculate Red and Green Sales with 

 

CALCULATE ( [SalesAmount], Sales[Color] in {"Red", "Green"} )

 

But what if I do not know if this should be Red or Green? I keep values to be filtered in a separate table ColorTable, that consists of a few values to be filtered. Tried these, but they don't seem to work:

 

CALCULATE ( [SalesAmount], Sales[Color] in { ColorTable[Value] } )
CALCULATE ( [SalesAmount], FILTER ( All(Sales), Sales[Color] in { ColorTable[Value] } ) )

 

What am I missing here?

Thanks.

  • Hey gvg ,

     

    Try using TREATAS:

     

    CALCULATE (
        [SalesAmount],
        TREATAS (
            VALUES ( ColorTable[Value] ),
            Sales[Color]
        )
    )

     I hope this gives you the desired result

2 Replies

  • PC2790's avatar
    PC2790
    Community Champion

    Hey gvg ,

     

    Try using TREATAS:

     

    CALCULATE (
        [SalesAmount],
        TREATAS (
            VALUES ( ColorTable[Value] ),
            Sales[Color]
        )
    )

     I hope this gives you the desired result