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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
lastnn30
Post Patron
Post Patron

using substitute () to change 2 values.

Hi

I have a column called Gender which has values like M, and F. I want to use Subsitute() to replace M to Male and F to Female. So what I created a New Column and I wrote this dax

 

Gender_full = subsitute(Table1(Gender), "M", "Male"")

 

But that only change M to Male, how can I write one Dax function to subsitute both M and F at same time.

Thank you very much.SNAG-0086.jpg

3 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

@lastnn30 You might kick yourself:

Gender Full Column = 
    SUBSTITUTE(
        SUBSTITUTE([Gender],"M","Male"),
        "F", "Female"
    )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

smpa01
Super User
Super User

@lastnn30  you can create a mapping table and utilize moving forward

 

Column =
VAR mapping =
    DATATABLE (
        "lookup", STRING,
        "val", STRING,
        {
            { "Male", "M" },
            { "M", "M" },
            { "F", "F" },
            { "Female", "F" }
        }
    )
RETURN
    MAXX (
        FILTER ( mapping, [lookup] = CALCULATE ( MAX ( 'Table'[Column1] ) ) ),
        [val]
    )

 

smpa01_0-1675720352799.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

FreemanZ
Super User
Super User

hi @lastnn30 

you may also try like:

Gender_full = IF([Gender]="M", "Male", "Female")

View solution in original post

3 REPLIES 3
FreemanZ
Super User
Super User

hi @lastnn30 

you may also try like:

Gender_full = IF([Gender]="M", "Male", "Female")
smpa01
Super User
Super User

@lastnn30  you can create a mapping table and utilize moving forward

 

Column =
VAR mapping =
    DATATABLE (
        "lookup", STRING,
        "val", STRING,
        {
            { "Male", "M" },
            { "M", "M" },
            { "F", "F" },
            { "Female", "F" }
        }
    )
RETURN
    MAXX (
        FILTER ( mapping, [lookup] = CALCULATE ( MAX ( 'Table'[Column1] ) ) ),
        [val]
    )

 

smpa01_0-1675720352799.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Greg_Deckler
Community Champion
Community Champion

@lastnn30 You might kick yourself:

Gender Full Column = 
    SUBSTITUTE(
        SUBSTITUTE([Gender],"M","Male"),
        "F", "Female"
    )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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