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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

How to replace value in Calculated table. One demo code enclosed for your reference

  1. SSL =
  2.  
  3.  
  4. VAR Unique_SSL = DISTINCT(
  5.     UNION(
  6.         VALUES('Base file Current week'[SSL]),
  7.         VALUES(CIS[SSL]),
  8.         VALUES(YOY[SSL]),
  9.         VALUES('YTD Utilization'[_SSL])
  10.         )
  11.     )
  12.  
  13.  
  14. VAR Updated_Table  = ADDCOLUMNS(Unique_SSL,"_SSL",REPLACE(Unique_SSL[SSL],1,1,1))
  15.  
  16.  return Updated_Table
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

We can create a new table.

Demo = 
// 01) Create one demo table
VAR MYTable = GENERATESERIES(1, 10)
// 02) Modify the table based on certain conditions
VAR ModifiedTable =
    ADDCOLUMNS(
        MYTable,
        "UpdatedValue",
        IF([Value] <= 5, CONVERT(REPLACE( [Value],1,LEN([Value]),10),INTEGER), [Value])
    )

// 03) Return the modified table
RETURN ModifiedTable

The variable utilizes an if function that replaces [value] with 10 if the table has [value] <= 5 and vice versa to keep the original number.

vtangjiemsft_0-1689043440980.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

 

View solution in original post

3 REPLIES 3
TomMartens
Super User
Super User

Hey @Anonymous ,

 

please describe the expected result based on sample data. The DAX formula provided will replace the substring of length 1 of the column with 1. Here you will find a description of the function REPLACE: https://dax.guide/replace/

Regards,
Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

Hi Tom,

Thanks for your response. My core requirement is.
IE:
01) I just created a virtual table then and saved them into variable.
02) I need to made few change like replace some value on behalf of certain condition or add some filter on columns within virtual table. It can be anything.
03) Once it done, just simply return the modified variable


Demo =
// 01) Create one demo table
VAR MYTable = GENERATESERIES(1,10
 
//02)  Need to select their columns into virtual table ande replace some value within it.
VAR Update_Table = REPLACE( MYTable[Value],1,LEN(MYTable[Value]),10)
 
//03) return modified table
return MYTable
Anonymous
Not applicable

Hi @Anonymous ,

 

We can create a new table.

Demo = 
// 01) Create one demo table
VAR MYTable = GENERATESERIES(1, 10)
// 02) Modify the table based on certain conditions
VAR ModifiedTable =
    ADDCOLUMNS(
        MYTable,
        "UpdatedValue",
        IF([Value] <= 5, CONVERT(REPLACE( [Value],1,LEN([Value]),10),INTEGER), [Value])
    )

// 03) Return the modified table
RETURN ModifiedTable

The variable utilizes an if function that replaces [value] with 10 if the table has [value] <= 5 and vice versa to keep the original number.

vtangjiemsft_0-1689043440980.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

 

Helpful resources

Announcements
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.