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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Anonymous
Not applicable

Help with if function

Hello community members, 

 

I have the following question

 

Next year, a few healthcare products will be categorized in a new way, therefore I made a calculated column with the following formula to define who is going to get which product. 

 

ProductA = 
IF(
ClientHash[Age] = "75 and older"
&& ClientHash[Product] = "01A04"
&& ClientHash[Volume] >= 3,
"Product A",
"Other product"
)

 

This works in the simple casus, but I have an issue in the following situation: 

 

When I need to decide if someone gets in the future 'ProductB', they need to have the following requirements:  

Client Age = 75 and older

AND

Client receives Product 01A04 or 02B04 with a Volume of 3 or more and Duration is >1

AND

Client recieves Product 07B03 or 07B04 or 07B05 with a Volume of 2 or more and Duration is >1

 

Can somebody help me with rewriting my initial formula? I get stuck with the product combination and the fact that the information of 1 client is specificied on more rows (each product per client = 1 row), see data example below

 

ClientAgeVolumeDurationProduct
175 and older51,201A04
275 and older31,501A04
275 and older3207B03
375 and older42,502B04
375 and older31,307B03

 

I hope to hear soon from you! 

 

Best regards, 

 

Sander

1 ACCEPTED SOLUTION
selimovd
Most Valuable Professional
Most Valuable Professional

Hey @Anonymous ,

 

it's a little tricky to check that.

At the moment for me the most undertandable approach is to filter for the two complex product criteria on their own and if both criteria give a result per customer, then it should be Product B.

Check the following formula:

ProductB = 
VAR vRowClient = ClientHash[Client]
VAR vCheckProduct1 =
    FILTER(
        ClientHash,
        ClientHash[Client] = vRowClient
            && ClientHash[Age] = "75 and older"
            && ClientHash[Product] in { "01A04" ,"02B04"}
            && ClientHash[Volume] >= 3
            && ClientHash[Duration] > 1
    )
VAR vCheckProduct2 =
    FILTER(
        ClientHash,
        ClientHash[Client] = vRowClient
            && ClientHash[Age] = "75 and older"
            && ClientHash[Product] IN { "07B03", "07B04", "07B05" }
            && ClientHash[Volume] >= 2
            && ClientHash[Duration] > 1
    )
RETURN
    IF(
        COUNTROWS( vCheckProduct1 ) > 0 && COUNTROWS( vCheckProduct2 ) > 0,
        "Product B",
        "Other product"
    )

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

2 REPLIES 2
selimovd
Most Valuable Professional
Most Valuable Professional

Hey @Anonymous ,

 

it's a little tricky to check that.

At the moment for me the most undertandable approach is to filter for the two complex product criteria on their own and if both criteria give a result per customer, then it should be Product B.

Check the following formula:

ProductB = 
VAR vRowClient = ClientHash[Client]
VAR vCheckProduct1 =
    FILTER(
        ClientHash,
        ClientHash[Client] = vRowClient
            && ClientHash[Age] = "75 and older"
            && ClientHash[Product] in { "01A04" ,"02B04"}
            && ClientHash[Volume] >= 3
            && ClientHash[Duration] > 1
    )
VAR vCheckProduct2 =
    FILTER(
        ClientHash,
        ClientHash[Client] = vRowClient
            && ClientHash[Age] = "75 and older"
            && ClientHash[Product] IN { "07B03", "07B04", "07B05" }
            && ClientHash[Volume] >= 2
            && ClientHash[Duration] > 1
    )
RETURN
    IF(
        COUNTROWS( vCheckProduct1 ) > 0 && COUNTROWS( vCheckProduct2 ) > 0,
        "Product B",
        "Other product"
    )

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 
Anonymous
Not applicable

@selimovd Thanks for your help! This works perfect! 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.