Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello,
My table looks like this:
allocation1 | allocation2 | allocation3 | rule |
0001 | 784 | 4741 | leader |
999 | 0006 | 4147 | visitor |
2222 | 11 | 008 | general |
1111 | 111 | 111 | visitor |
I want to create a new column called "receiver" that checks the value of the "rule" column.
° If rule = "leader" then receiver = allocation1
° If rule = "visitor" then receiver = allocation2
º If rule = "general" then receiver = allocation3
The result should look like this:
allocation1 | allocation2 | allocation3 | rule | receiver |
0001 | 784 | 4741 | leader | 0001 |
999 | 0006 | 4147 | visitor | 0006 |
2222 | 11 | 008 | general | 008 |
01478 | 111 | 66666 | visitor | 111 |
I created the following code for the column:
but an error appears "expressions that generate variable data types cannot be used to define calculated columns"
Solved! Go to Solution.
@Anonymous , this a data type issue. Check all three should have the same data type
You can try like this also
switch( true(),
table[rule]="leader", table[allocation1] &"",
table[rule]="visitor", table[allocation2] & "",
table[rule]="general", table[allocation3] & ""
)
@Anonymous Try this:
receiver = IF(table[rule]="leader", table[allocation1] & "", IF(table[rule]="visitor", table[allocation2] & "", IF(table[rule]="general", table[allocation3] & "")))
This will ensure that you are always returning text.
@Anonymous , this a data type issue. Check all three should have the same data type
You can try like this also
switch( true(),
table[rule]="leader", table[allocation1] &"",
table[rule]="visitor", table[allocation2] & "",
table[rule]="general", table[allocation3] & ""
)
User | Count |
---|---|
130 | |
108 | |
101 | |
67 | |
62 |
User | Count |
---|---|
137 | |
115 | |
102 | |
71 | |
61 |