Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
18 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
23 | |
10 | |
10 | |
9 | |
7 |