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'm trying to create a new column that looks at an existing column called % Completed (if contains numerical values from 0 to 1 and blanks) and then outputs text based off what value is in that column. I've tried a bunch of formats. No luck. Here is the gist...
If % Completed = 1, "100% Completed"
elseif % Completed <1 but > .66, "Knowledge Stage Completed"
elseif % Completed <.661 but > 0, "Learning Started"
elseif % Completed = 0, "Not Started"
elseif % Competed = blank/null, "Account created, Not Started"
Are you doing this in DAX or M? I'd use a SWITCH statement in DAX, SWITCH(TRUE()...)
Thanks Greg, always happy when I see you on a thread!
I am using DAX, and had tried the SWITCH statement. My challenge was more around all the conditions - I'm getting a "Too many arguments were passed to the AND function. The maximum argument count for the function is 2.". I had hoped I had done enough isolation of the IF(AND statements to allow for this to work. here is my formula...
HI @Anonymous,
I'd like to recommend you to use if statement to nested switch function instead of combine them in switch function, switch function not suitable to compare with data range.
Column = IF ( AND ( [% Completed] > 0, [% Completed] < .661 ), "Learning Started", IF ( AND ( [% Completed] > .66, [% Completed] < 1 ), "Knowledge Stage Completed", SWITCH ( [% Completed], 1, "100% Completed", 0, "Not Started", "", "Account Created, Not Started" ) ) )
Regards,
Xiaoxin Sheng
Thank you for this. When I entered that formula, I got the following error:
Function 'SWITCH' does not support comparing values of type Number with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.
HI @Anonymous,
I add value function to switch to convert value to number, maybe you can try to use following formula:
Column = IF ( AND ( [% Completed] > 0, [% Completed] < .661 ), "Learning Started", IF ( AND ( [% Completed] > .66, [% Completed] < 1 ), "Knowledge Stage Completed", SWITCH ( VALUE ( Table[% Completed] ), 1, "100% Completed", 0, "Not Started", "", "Account Created, Not Started" ) ) )
Regards,
Xiaoxin Sheng
Thank you. Came back with another error - The syntax for 'Table' is incorrect. (DAX(IF ( AND ( [% Completed] > 0, [% Completed] < .661 ), "Learning Started", IF ( AND ( [% Completed] > .66, [% Completed] < 1 ), "Knowledge Stage Completed", SWITCH ( VALUE ( Table [% Completed] ), 1, "100% Completed", 0, "Not Started", "", "Account Created, Not Started" ) )))).
I couldn't find an expression called Table
Hi @Anonymous,
Table means your table name who host the column.(where [% Completed] field exists)
Regards,
Xiaoxin Sheng
Column = IF ( AND ( [% Completed] > 0, [% Completed] < .661 ), "Learning Started", IF ( AND ( [% Completed] > .66, [% Completed] < 1 ), "Knowledge Stage Completed", SWITCH ( VALUE ( Table[% Completed] ), 1, "100% Completed", 0, "Not Started", "", "Account Created, Not Started" ) ) )
I'm now seeing a Function 'SWITCH' does not support comparing values of type Number with values of type Text error. Consider using the VALUE or FORMAT function to convert one of the values. I tried formatting the column (which was set to Decimal Number and General) to Decimal Number and Decimal Number - didn't help.
Doh. Forrest for the trees....
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 | |
100 | |
78 | |
76 | |
52 |
User | Count |
---|---|
144 | |
109 | |
108 | |
88 | |
61 |