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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

How to remove garbage values or scripted value from a column in calculated table?

Hi All,

I need help with removing garbage values or scripted value from a column in calculated table. 

 

Calculated Table: Products

Current Column: Product

Trying to create a new calculated column: Product Name

 

Table

ProductProduct Name
{"cs-CZ":"10x iD POLAR GREEN","cs":"10x iD POLAR GREEN"}10x iD POLAR GREEN:10x iD POLAR GREEN
{"cs-CZ":"Čisticí tampóny","cs":"Čisticí Tampóny"}Čisticí tampóny:Čisticí Tampóny
{"cs-CZ":"Čisticí tyčinky","cs":"Čisticí Tampóny"}Čisticí tyčinky:Čisticí Tampóny

 

This is not possible in Power Query as this is a calculated table. Could someone help me with DAX expression?

1 ACCEPTED SOLUTION
tackytechtom
Super User
Super User

Hi @Anonymous ,

 

tomfox_0-1649696027353.png

 

Here the DAX:

Column = 
IF ( Table[Country] = "US", 
    SUBSTITUTE (
        SUBSTITUTE (
            SUBSTITUTE ( Table[Product], "-US", "" )
            , "{""en"":""", ""
        )
        , """}", ""
    ),
    ""
)

 

I do not think you need an OR, at least not in the case that you are describing above. You can just add a step beforehand to make the values look alike. I.e. in the DAX above you can see that we first removed "-US" from the string. Afterwards, it has the exact same structure.

 

DAX really is not the right tool for string interpolation / manipluation. As already said yesterday, this should be done in PQ. Further, calculating tables can also be done in PQ, so there should indeed be a decent chance that your calculated table can already be created in PQ. You might wanna consider posting that in the Power Query Forum 🙂

 

Hope this helps anyway 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

3 REPLIES 3
tackytechtom
Super User
Super User

Hi @Anonymous ,

 

tomfox_0-1649696027353.png

 

Here the DAX:

Column = 
IF ( Table[Country] = "US", 
    SUBSTITUTE (
        SUBSTITUTE (
            SUBSTITUTE ( Table[Product], "-US", "" )
            , "{""en"":""", ""
        )
        , """}", ""
    ),
    ""
)

 

I do not think you need an OR, at least not in the case that you are describing above. You can just add a step beforehand to make the values look alike. I.e. in the DAX above you can see that we first removed "-US" from the string. Afterwards, it has the exact same structure.

 

DAX really is not the right tool for string interpolation / manipluation. As already said yesterday, this should be done in PQ. Further, calculating tables can also be done in PQ, so there should indeed be a decent chance that your calculated table can already be created in PQ. You might wanna consider posting that in the Power Query Forum 🙂

 

Hope this helps anyway 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

tackytechtom
Super User
Super User

Hi @Anonymous ,

 

As you said yourself, Power Query would be a much better option, but if it really does not work to create the calculated table in PQ, here a possible solution:

tomfox_0-1649615341873.png

 

Here the code:

Column = 
SUBSTITUTE (
    SUBSTITUTE ( 
        SUBSTITUTE ( 
            SUBSTITUTE ( Table6[Product], "{""cs-CZ"":""", "" )
            , """,""cs""", "" 
        )
        ,"""", "" 
    )
    , "}", ""
)

 

Does this solve your issue? 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Anonymous
Not applicable

hi @tackytechtom ,
Thanks this is helping me to some extent but if the country is having two different types of script language it is working partially.

 

For eg: if "US" country is having two different types of script as shown below

 

Capture_PN.JPG

 

The formulae I am using for calculated column is :

Product Name =
Capture_PNDAX.JPG

I tried to add OR check but it is throwing error. Could you please help me here?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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