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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Use a variable in a calculated column

Hi, so I created a column that display "true" or "false" if the conditions are matching.

 

Screen Shot 09-16-19 at 04.19 PM.PNG

 

I would like to know if there is a way to create a variable, X=757_501, for example, and replace every "787_501" by this X in my formula. I would like to do this because I might often want to change this number in the future. And changing the value of 1 variable is faster than changing it 15 times in a formula.

I tried to do this through measures but it didn't work as planned

 

Thanks !

 

1 ACCEPTED SOLUTION
AnthonyTilley
Solution Sage
Solution Sage

YES you can use veriables in dax

 

for example

Query Bugs = 

Var T = "787_501"

Var ret = <put your dax here and replace each instance on text with T>

Return ret

Where you need to combine your veriable in a string just use a & 

fore example where you have "test 787_501" replace with "test " & T 

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

Use VAR to create variable and use substitute to replace value 

 

Sample how 

YTD Sales = 
Var var= "XYX"
Return
 substitute()......
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
AnthonyTilley
Solution Sage
Solution Sage

YES you can use veriables in dax

 

for example

Query Bugs = 

Var T = "787_501"

Var ret = <put your dax here and replace each instance on text with T>

Return ret

Where you need to combine your veriable in a string just use a & 

fore example where you have "test 787_501" replace with "test " & T 

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

The answer was under my eyes since the beginning, you can't even imagine every things I tried knowing this VAR function...
Thanks 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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