Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
In the table below, the column 'final result' is the new column that I need to produce from columns 'unit' and 'result'. The rules for creating 'final result' are:
Question: What is the DAX script to produce the column 'final result'?
Thanks in advance
Solved! Go to Solution.
Hi @pmcinnis
try a new calculated column
final result = SWITCH(TRUE(),
'Table'[unit]="x",1000*'Table'[result],
'Table'[unit]="y",'Table'[result],
'Table'[unit]="z",'Table'[result]/1000,
ISBLANK('Table'[unit]) && ISBLANK('Table'[result]),BLANK(),
ISBLANK('Table'[unit]) && ISNUMBER('Table'[result]),'Table'[result],
"Undefined"
)
do not hesitate to give a kudo to useful posts and mark solutions as solution
Hi @pmcinnis
try a new calculated column
final result = SWITCH(TRUE(),
'Table'[unit]="x",1000*'Table'[result],
'Table'[unit]="y",'Table'[result],
'Table'[unit]="z",'Table'[result]/1000,
ISBLANK('Table'[unit]) && ISBLANK('Table'[result]),BLANK(),
ISBLANK('Table'[unit]) && ISNUMBER('Table'[result]),'Table'[result],
"Undefined"
)
do not hesitate to give a kudo to useful posts and mark solutions as solution
Thanks, that worked great. What is the purpose of the TRUE function near the beginning of the script?
SWITCH syntax is
SWITCH(<expression>, <value1>, <result1>, <value2>, <result2>, <else>)
in the most common case as expression used Column.
it works as follow:
First, value1 compares with expression. if equals = result`, if not - goes to value2 and so on.
As you have more sophisticated condition in values, you can not to compare it with the only column. So, TRUE() allows you to compare complex conditions with true(), like if
ISBLANK('Table'[unit]) && ISBLANK('Table'[result]) = TRUE()
then return desired result
do not hesitate to give a kudo to useful posts and mark solutions as solution
Ah, I see, thanks for clarifying!
Thanks for the quick reply, let me look into this
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
77 | |
74 | |
57 | |
40 | |
35 |
User | Count |
---|---|
65 | |
65 | |
59 | |
53 | |
45 |