Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I am trying to use IF() function to create a measure and put it into a matrix, but the following two screenshots showed me no column selection when I am trying to give a condition statement to IF() function. The column I am going to refer to is "S/T" (which shows in the third graph, it is a column created by PowerQuery Editor).
The complete measure that I would like to make is as below:
Turnaround Time / Box =
IF('new vessel'[S/T]="S",
CALCULATE(AVERAGEX('new vessel',
'new vessel'[New Off Chassis Time]-'new vessel'[New Hot Time]),
ALLEXCEPT('new vessel','new vessel'[Tractor Cycle Id])
),
CALCULATE(AVERAGEX('new vessel',
'new vessel'[New Off Chassis Time]-'new vessel'[New Hot Time]),
ALLEXCEPT('new vessel', 'new vessel'[Tractor Cycle Id])
)
)
To handle this situation, I tried to turn into using calculated column instead of using measure. And turns out it works.
Can someone explain a little bit why the IF() function is so interesting that it works only in calculated column? Or how can I do to make it work in measure?
Solved! Go to Solution.
Because in the measures there is no row context, but only filter context.
This is why you need a column as first parameter of the IF function if you want to create a calculated column, instead if you want to create a measure, the first parameter does not accept a column.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Because in the measures there is no row context, but only filter context.
This is why you need a column as first parameter of the IF function if you want to create a calculated column, instead if you want to create a measure, the first parameter does not accept a column.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
try to use in the measure
IF(SELECTEDVALUE('new vessel'[S/T]) = "S"
Nice, it works. But I am wondering why it works, and why my original approach doesn't work?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
99 | |
80 | |
70 | |
59 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |