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.
Hi all,
I have a table (see below) with the Absolute Percent Error of three different models. I'd like to create a custom column with the "best" (lowest APE) of those three.
In Excel, I have =MIN(Table[@[Model 1 APE]:[Model 3 APE]])
What's the PQ equivalent? I'm unsure how to specify a range of columns.
As usual, thanks!
Solved! Go to Solution.
So really, we should not use a calculated column in DAX. It will result in the column being recaulclated every time and slow performance.
You could write a measure, which would not store a value for every row. As you asked for a column, instead, we should do this in the query editor. This will mean it is only calculated on a data refresh, and stored in the model.
In the query editor, go to the query, and select "Add Custom Column".
The code you can use is:
each if [Model 1 APE] = [Model 2 APE]then "N/A" else if [Model 1 APE]< [Model 2 APE] then "Model 1 APE" else if [Model 2 APE]< [Model 1 APE] then "Model 2 APE"
else "N/A"
Here, the second else if statement is a bit redundant, but I left it in so that you can add more logic if you wanted, to compare more models. You can add as many "else if" statements to use any logic you wish.
Did I answer your question? Mark my post as a solution! Proud to be a Super User!
Connect with me!
Stay up to date on
Read my blogs on
So really, we should not use a calculated column in DAX. It will result in the column being recaulclated every time and slow performance.
You could write a measure, which would not store a value for every row. As you asked for a column, instead, we should do this in the query editor. This will mean it is only calculated on a data refresh, and stored in the model.
In the query editor, go to the query, and select "Add Custom Column".
The code you can use is:
each if [Model 1 APE] = [Model 2 APE]then "N/A" else if [Model 1 APE]< [Model 2 APE] then "Model 1 APE" else if [Model 2 APE]< [Model 1 APE] then "Model 2 APE"
else "N/A"
Here, the second else if statement is a bit redundant, but I left it in so that you can add more logic if you wanted, to compare more models. You can add as many "else if" statements to use any logic you wish.
Did I answer your question? Mark my post as a solution! Proud to be a Super User!
Connect with me!
Stay up to date on
Read my blogs on
Wow. Somehow, after almost three years of using Power BI, I entirely forgot about the Conditional Column button. Thanks for the support!
You can try:
New Column = _min_amnt = min([Model 1 APE],min([Model 2 APE],[Model 3 APE]) RETURN SWITCH( _min_amnt, [Model 1 APE], "Model 1 APE", [Model 2 APE], "Model 2 APE", [Model 3 APE], "Model 3 APE", "None" )
Although, this will not work in case of ties, and pick the first. What would be the desired solution if all 0, for example?
Did I answer your question? Mark my post as a solution! Proud to be a Super User!
Connect with me!
Stay up to date on
Read my blogs on
How about with two columns (Model 1 and 2)? In the case of a tie/all zero, display "N/A."
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 |
---|---|
111 | |
100 | |
80 | |
64 | |
58 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |