Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Multiple condition

Hello Dear Community, I hope you are well. I have a small problem. I have created a column that gives me categories based on the content of a cell in another column. Here is the formula :  GBU/...
  • AlexisOlson's avatar
    AlexisOlson
    4 years ago

    Is this better?

    GBU/GF = 
    VAR ProdElements =
        CALCULATETABLE (
            VALUES ( Example[Element] ),
            ALLEXCEPT ( Example, Example[Product_ID] ),
            Example[Dimension] = "GMC"
        )
    VAR Elements =
        FILTER (
            { "CHC", "SPC", "VAC", "GENMED", "GLOBAL" },
            NOT ISEMPTY (
                FILTER ( ProdElements, CONTAINSSTRING ( Example[Element], [Value] ) )
            )
        )
    RETURN
        SWITCH (
            TRUE (),
            COUNTROWS ( Elements ) = 2 && "GLOBAL" IN Elements, EXCEPT ( Elements, { "GLOBAL" } ),
            COUNTROWS ( Elements ) > 1, "MBC",
            COUNTROWS ( Elements ) = 1, Elements,
            "GLOBAL"
        )