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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Dayna
Helper V
Helper V

Nested if / switch on text result

Hello,

 

I'd like a measure that showed a different value for the field depending on the category. I understand I need to aggregate this, but I'm not sure what text aggregation to use.

 

In summary, if type = 1, then I want to show pattern and colour. If type = 2, then I want to show material and category, if type = 3... etc...

 

I got as far as doing this as a switch, rather than nested if, but how do I aggregate this?

 

SWITCH (
TRUE (),
Items[TypeId] = 1 || Items[TypeId] = 2 || Items[TypeId] = 16, VALUES(Applicators[ApplicatorPatterns.Name]),
Items[TypeId] = 3, VALUES(Corrugates[Finish]),
"N/A"
)
 
Many thanks for any assistance!
 
Kind Regards,
Dayna
6 REPLIES 6
v-juanli-msft
Community Support
Community Support

Hi @Dayna 

What do you mean by "aggregate this measure"?

 

As tested with your formula, it will return only one value for each Items[TypeId].

Even there are many different values for each id.

Measure =
SWITCH (
    TRUE (),
    MAX ( Items[TypeId] ) = 1
        || MAX ( Items[TypeId] ) = 2
        || MAX ( Items[TypeId] ) = 16, MAX ( Applicators[ApplicatorPatterns.Name] ),
    MAX ( Items[TypeId] ) = 3, MAX ( Corrugates[Finish] ),
    BLANK ()
)

7.png

 

If you want to return all values for each id, you could create a table

Table =
UNION (
    UNION (
        FILTER (
            SELECTCOLUMNS (
                Applicators,
                "id", [TypeId],
                "value", [ApplicatorPatterns.Name]
            ),
            [id] = 1
                || [id] = 2
                || [id] = 16
        ),
        FILTER (
            SELECTCOLUMNS ( Corrugates, "id", [TypeId], "value", [Finish] ),
            [id] = 3
        )
    ),
    FILTER (
        SELECTCOLUMNS ( Items, "id", [TypeId], "value", " " ),
        [id] <> 1
            && [id] <> 2
            && [id] <> 3
            && [id] <> 16
    )
)

8.png

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Maggie,

 

Many thanks for your help, the aggregration I think I meant was something like the MAX that you put into your formula, as that brings back the results as I'd expect.

 

As far as the table, the TypeId comes from a table called 'items', whereas the value (i.e. the Applicator Pattern) comes from the applicator table. There is a relationship between these two tables. However, the example you provided doesn't work as it is looking for the TypeId within the Applicators table, which doesn't exist. Can you advise, please?

 

Many thanks for your help, it is much appreciated!

 

Kind regards,

Dayna 

Hi @Dayna 

"However, the example you provided doesn't work as it is looking for the TypeId within the Applicators table, which doesn't exist."

 

Sorry, i'm not clear.

Could you clear me?

 

You can give an example for solution 2- create a table:

with my test tables, what's expected table?

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Maggie,

 

Of course. I have three tables: "Items", "Corrugates" and "Applicators".

Corrugates links to the Items table on Id (Corrugates) to Id (Items)

Applicator links to the Items table on Id (Applicator) to Id (Items)

 

My end result is to be able to have one table like your original post, where there's the Id and the Value. 

 

Example items data:

IdItem Types.Items.TypeNameTypeId
31721Corrugated1
31722Corrugated1
31724Corrugated1
31725Corrugated1
31726Corrugated1
31727Corrugated1
31728Corrugated1
31729Corrugated1
31731Corrugated1
31732Corrugated1
31733Corrugated1
31734Corrugated1
31736Corrugated1
31737Corrugated1
31739Corrugated1
31740Corrugated1
31741Corrugated1
31742Corrugated1
31743Corrugated1
31744Corrugated1
38083Applicator1
38084Applicator1
38085Applicator1
38086Applicator1
38087Applicator1
38088Applicator1
38089Applicator1
38090Applicator1
38091Applicator1
38092Applicator1
38093Applicator1
38094Applicator1
38095Applicator1
38096Applicator1
38097Applicator1
38098Applicator1
38099Applicator1

 

Example Applicator Data:

IdApplicatorTypes.NameApplicatorPatterns.Name

37836Airlaid 
37837ThermobondedDots
37838AirlaidPlain
37839Dispersible WetlaidPlain
37840SpunlacePlain
37841AirlaidToys
37842AirlaidToys
37843SpunlacePlain
37844Airlaid 
37845AirlaidToys
37846SpunlacePlain
37847SpunlacePlain
37848Dispersible WetlaidPlain
37849Dispersible WetlaidPlain
37850SpunlacePlain
37851Airlaid 
37852AirlacePlain
37853Airlaid 

 

Example Corrugate Data:

IdFinish

31721Plain
31722Plain
31724Plain
31725Plain
31726Printed
31727Plain
31728Plain
31729Plain
31731Plain
31732Plain
31733Plain
31734Plain
31736Plain
31737 

 

Hopefully that clarifies it?


Many thanks for your help!

 

Kind Regards,

Dayna

v-juanli-msft
Community Support
Community Support

Hi @Dayna 

Is there any relationship between two tables below?

Items table

TypeId
1
2
3

Applicators table

ApplicatorPatterns.Name
pattern
colour
material
category

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Maggie, 

 

There is indeed, it's a one to many relationship from the items table, to the applicators table.

 

It is a direct relationship; but the applicator table has had a few other tables merged into it. Not sure if that makes a difference!

 

Many thanks for your help,

Dayna

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.