Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

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/GF = SWITCH(TRUE(),IF(SEARCH("CHC", Example[Element], 1, 0) > 0 && SEARCH("GMC", [Dimension], 1, 0) > 0
,TRUE() ,FALSE() ),"CHC",IF(SEARCH("SPC",Example[Element], 1, 0) > 0 && SEARCH("GMC", [Dimension], 1, 0) > 0
,TRUE() ,FALSE() ),"SPC",IF(SEARCH("VAC", Example[Element], 1, 0) > 0 && SEARCH("GMC", [Dimension], 1, 0) > 0
,TRUE() ,FALSE() ),"VACCIN",IF(SEARCH("GENMED", Example[Element], 1, 0) > 0 && SEARCH("GMC", [Dimension], 1, 0) > 0
,TRUE() ,FALSE() ),"GENMED","GLOBAL" )


The problem is that when I format this, I realize that the total of the products is not good.
By investigating a little, I noticed that some products are in several categories.
I would like to add a condition that would say if you belong to more than one category other than Global then it is MBU.
In the example PBI, I have put everything, including a text box where I explain in detail.
I tried to make a copy of the table and play with the groupings and conditional columns but I still have more products.

 

Thank you very much for your future help.

 

Example Files 

1 ACCEPTED SOLUTION

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"
    )

AlexisOlson_0-1639411341144.png

 

View solution in original post

9 REPLIES 9
AlexisOlson
Super User
Super User

I don't see any elements in your example that have multiple categories but something like this should be closer to what you're after:

 

GBU/GF =
VAR Elements =
    FILTER (
        { "CHC", "SPC", "VAC", "GENMED", "GLOBAL" },
        CONTAINSSTRING ( Example[Element], [Value] )
    )
RETURN
    SWITCH (
        TRUE (),
        Example[Dimension] <> "GMC", "GLOBAL",
        COUNTROWS ( Elements ) > 1, "MBC",
        COUNTROWS ( Elements ) = 1, Elements,
        "GLOBAL"
    )

 

Anonymous
Not applicable

hello @AlexisOlson , 

 

Thank you for your answer. 

Your formula doesnt work in my situation. 

I insert a text box to show you some users who have more than one Example 

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"
    )

AlexisOlson_0-1639411341144.png

 

Anonymous
Not applicable

here is perhaps a simply view : 

DimitriD_0-1639414324940.png

the target : 

DimitriD_1-1639414372697.png

 

If the product has several elements (other than GLOBAL ex: CHC and SPC ) then Multi
If the product has only one product it keeps its element

We count Global only if product have ONLY GLOBAL (ex : CHC and GLOBAL then we keep CHC)

 

Thank you 

 

Yes, this is what my logic is doing.

 

According to your original post, it's also using "GLOBAL" when it doesn't match anything else.

Anonymous
Not applicable

Hello @AlexisOlson

 

Thank you very much for your time and answer. 

The total amount is 4116. 

Is it working for you ? 

 

Not sure where you're getting that number from. The file you provided has 4,455 distinct Product_ID values.

David-Ganor
Resolver II
Resolver II

Hi @Anonymous 

You might consider to change the true/false into 1 and 0...

Than instead of switch - just sum it...

Meaning: condition 1 + condition 2...etc...

If it is greater than 1..than MBU...

Other wise - your original formula...

Anonymous
Not applicable

Hello @David-Ganor 

 

I dont understand your suggestion. 

Target is to have a new categories because some users have more than one (ex: Genmed and Vaccin, .. ) 

If I change my condition like if element contain "CHC" then 1 and same for the other like 

Global = O, CHC=1, .. After I make a sum of rows how to determine the new categorie

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.