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
Caitlin_Knox
Advocate III
Advocate III

IF formula based on format of value

I'm wondering if anyone has any suggestions for me. I have a column that contains multiple values. The format of these values determines the type (2 types). The determinig factor is an added '-' + digits at the end.

The type column is not existing in my data set, that's just to illustrate the difference. How can I include an IF Statement to return a column like 'Type'?  The rule would read 'Any value containing a dash is b and any value without a dash is a'

valuetype
100a
200a
300a
300-01b
100-01b
200-01b
200-02b

 

 

1 ACCEPTED SOLUTION

Or you can use the "Add conditional column" functionality.

 

Coincidentally, @Sean and I responded to a similar question today.

Specializing in Power Query Formula Language (M)

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Caitlin_Knox

 

Assuming the first three values are numbers and not text then the code would be:

 

let
    source = #table( {"value"},
            {
            {100},{200},{300},{"300-01"},{"100-01"},{"200-01"},{"200-02"}
            }),
    #"added custom" = Table.AddColumn(source, "type", each try 
                       if Number.IsNaN([value]) then null else "a" otherwise "b")
in
    #"added custom"

 

 

 

Or you can use the "Add conditional column" functionality.

 

Coincidentally, @Sean and I responded to a similar question today.

Specializing in Power Query Formula Language (M)

Thank you, this was just what I needed

Anonymous
Not applicable

this is weird!

there is no such option in the German Version!

added column deutsch.gif

 

Am I missing something?

 

@ImkeFhave you also observed this ??

The column should be formatted as text (or only contain text), then you will have the "Contains" option.

Specializing in Power Query Formula Language (M)
Anonymous
Not applicable

ok. Thanks @MarcelBeug

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

Top Solution Authors
Top Kudoed Authors