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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Alisea_MI
Advocate III
Advocate III

Dax if string starts with text

Hi,

 

I am new to Power BI and would highly appreciate help with a calculated column that takes the first character from a string, and if it is "7", returns "SMED (7xxx)", if a string starts with "8", returns "SMNA (8...)". Else null.  

Screenshot 2021-04-14 144528.jpg

 

Would be grateful for all the help!

 

 

 

 

 

1 ACCEPTED SOLUTION
selimovd
Super User
Super User

Hey @Alisea_MI ,

 

sure, that's possible.

Add the following calculated column:

My String Check =
IF(
    LEFT( myTable[SempleContractNo], 1 ) = "7",
    "SMED (7xxx)",
    IF(
        LEFT( myTable[SempleContractNo], 1 ) = "8",
        "SMED (8xxx)",
        BLANK()
    )
)

 

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

4 REPLIES 4
Alisea_MI
Advocate III
Advocate III

@amitchandak , I hope you don't take offence, both variants work fine, but I only can set one to "correct", so I too the first one.  Thank you once more!

selimovd
Super User
Super User

Hey @Alisea_MI ,

 

sure, that's possible.

Add the following calculated column:

My String Check =
IF(
    LEFT( myTable[SempleContractNo], 1 ) = "7",
    "SMED (7xxx)",
    IF(
        LEFT( myTable[SempleContractNo], 1 ) = "8",
        "SMED (8xxx)",
        BLANK()
    )
)

 

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
 

 

Hi @selimovd 
Thanks for the Idea which you are commented for this post
i am also facing same issue but it need's some more debugging in the dax, i have attached the screen shot appreciate your help on this 

AlanP514_0-1694147184444.png

Scenario : I need to create on matrix table in power bi and in the row feild i am using variable names 
So my requirment is if value is "starting" with Budget then one color else another color 

So that users can seggregate the budget and actual in easy way 

but inside table there one text start with Tyre Budget so that i need some idea how to over come this sitation


Thanks 
Hoping Best Solutions
Alan 

amitchandak
Super User
Super User

@Alisea_MI , You Can try a new column

switch(True(),

left([column],1) = "7","SMED (7xxx)",

left([column],1) = "8","SMNA (8...)"

)

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.