Forum Discussion
Else if function displaying the max date
- 6 years ago
Hi Anonymous ,
M language is based on the row levels to get the maximum of a column for example as you refer you need to pick up the List.Max.
Assuming that you want to pick up the maximum value of the duration column you need to do your column like:
= Table.AddColumn(Between, "Column", each if [Duration] >= 60 then "60 to " & Number.ToText (List.Max(#"PreviousStepName"[Duration])) else if [Duration] >= 30 then "30 to 59" else if [Duration] >= 11 then "11 to 29" else "0 to 10")I'm assuming that your duration column is in number format that is why we need to use the Number.ToText.
Also using the List.Max you need to reference the step you want to calculate the maximum and the column thats the part
List.Max(#"PreviousStepName"[Duration])
Anonymous
I think it will be better to use DAX to create the column.
Could you please the sample data and expected output?
I can't attach anything to here. Happy to do it in DAX, can't figure it out in there either!
The [Duration] column is a numerical column containing any number ranging from 0 to 1000. At the moment, the highest value in there is 477. Tomorrow it will be different.
I want a new column which is of this logic:
If the [Duration] column is between 0 and 10, it says "0 to 10"
If the [Duration] column is between 11 and 29 it says "11 to 29"
If the [Duration] column is between 30 and 59 it days "30 to 59"
If the [Duration] column is over 60 it says "60 to 477"
- MFelix6 years ago
Super User
Anonymous ,
If you prefer DAX you can use:
Column = SWITCH ( TRUE (), 'Table'[Duration] >= 60, "60 to " & FORMAT ( CALCULATE ( MAX ( 'Table'[Duration] ), ALL ( 'Table'[Duration] ) ), "#" ), 'Table'[Duration] >= 30, "30 to 59", 'Table'[Duration] >= 11; "11 to 29", "0 to 10" )