Forum Discussion
Creating a new text colum based on a number range in another column
Hi all, new Powerbi user here,
I have been trying to find this via the forums, and many a re similar, but different enough to make the solutions not viable for me (I think).
I want to create a new column that gives a text output based on a number range in another column.
So, where column 1's value is between:
- 0 and 9, column 2 should show 'very low' in the corresponding row
- 10 and 30, column 2 should show 'low' in the corresponding row
- 31- 50, column 2 should show 'medium-low' in the corresponding row
- 51-60, column 2 should show 'Medium' in the corresponding row
- 61-70, column 2 should show 'Medium-high' in the corresponding row
- 71-90, column 2 should show 'High' in the corresponding row
- 91-100, column 2 should show 'Very low' in the corresponding row
I am thinking it is a ValueLookUp statement? But not sure of the syntax.
It's PowerQuery so it is just nested if then else statements:
if [Column] >= 0 and [Column] <= 0 then "Very Low" else if [Column] >= 10 and [Column] <= 30 then "Low" else ...
DAX would be cleaner. SWITHC(TRUE(), ...) is your friend here:
Column = SWITCH(TRUE(), [Column] >= 0 && [Column] <= 9, "Very Low", [Column] >= 10 && [Column] <= 30, "Low", [Column] >= 31 && [Column] <= 50, "Medium-Low", [Column] >= 51 && [Column] <= 60, "Medium", [Column] >= 61 && [Column] <= 70, "Medium-High", [Column] >= 71 && [Column] <= 90, "High", "Very High" )
2 Replies
- TriciaECIUNew Member
Greg_Deckler Thank you!
- Greg_Deckler
Community Champion
It's PowerQuery so it is just nested if then else statements:
if [Column] >= 0 and [Column] <= 0 then "Very Low" else if [Column] >= 10 and [Column] <= 30 then "Low" else ...
DAX would be cleaner. SWITHC(TRUE(), ...) is your friend here:
Column = SWITCH(TRUE(), [Column] >= 0 && [Column] <= 9, "Very Low", [Column] >= 10 && [Column] <= 30, "Low", [Column] >= 31 && [Column] <= 50, "Medium-Low", [Column] >= 51 && [Column] <= 60, "Medium", [Column] >= 61 && [Column] <= 70, "Medium-High", [Column] >= 71 && [Column] <= 90, "High", "Very High" )