Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi everyone,
I am looking at a code where variable countryOfBirth is defined inside an argument inside SELECTCOLUMNS which itself is inside another variable.
I wonder if this is the appropciate place to define such variable? Can it be defined outside the SELECTCOLUMNS statement?
thank you.
Solved! Go to Solution.
Hi @Nietzsche,
You can use the FORMAT(INT(RELATED(dimCountry[Code])), "0000") expression directly for later judgment instead of using a variable to store its return value.
But this makes the code very difficult to read and maintain.
If you declare a variable externally and then reassign a value to that variable, you cannot use the RETURN expression later.
Or declare the complete variable directly externally. However, this will not recognize the columns in the /dimCountry/ table.
Therefore, in general, this approach of yours to declaring variables is appropriate.
Best Regards,
Dengliang Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Nietzsche,
You can use the FORMAT(INT(RELATED(dimCountry[Code])), "0000") expression directly for later judgment instead of using a variable to store its return value.
But this makes the code very difficult to read and maintain.
If you declare a variable externally and then reassign a value to that variable, you cannot use the RETURN expression later.
Or declare the complete variable directly externally. However, this will not recognize the columns in the /dimCountry/ table.
Therefore, in general, this approach of yours to declaring variables is appropriate.
Best Regards,
Dengliang Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you very much for the detailed explanation.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 6 | |
| 5 | |
| 5 |
| User | Count |
|---|---|
| 24 | |
| 11 | |
| 9 | |
| 9 | |
| 8 |