Forum Discussion
Using Greater than to convert time above X to X
- 3 years ago
Creature Add a custom column with this formula:
if [Ticket Type] = "INC" and [time_worked] > 1200 then 1200 else [time_worked]Remove the original column, rename the new column to the name of the original column.
Creature Well, you could do something like this:
if [Ticket Type] = "INC" and [time_worked] IN { 0, 1, 2 } then 1200 else [time_worked]
Not sure if that is what you are asking.
So the same column has other ticket types that need to be modified as well - so the above formula makes all INC above 1200 = 1200 but what if I need to add more, SCTASK above 2000 = 2000 or INC below 1=1 etc into the same column with the above formula. Greg_Deckler
- Greg_Deckler3 years ago
Community Champion
Creature Oh, I understand now. Well, unfortunately M doesn't have a case or switch statement so you are stuck with nested if statements. ImkeF I think had some kind of way to simulate case/switch statements in Power Query so maybe she will stop by. Or edhans might have a good solution for it. But in nested if land it would be something like:
if [Ticket Type] = "INC" and [time_worked] > 1200 then 1200 else if [Ticket Type[time_worked] = "STK" and [time_worked] = 2000 then 2000 else if ... - Creature3 years agoFrequent Visitor
= Table.AddColumn(#"Extracted Text Before Delimiter", "Time Worked Rounded", each if [Ticket Type] = "INC" and [time_worked] > 1200 then 1200 else [time_worked])So this is what I currently have, I tried various ways of nesting and all returned an error. to make it easy for my solution Im trying to add and will need to do the same calc with other ticket types, tried your example didnt work or , didnt work etc
if [Ticket Type] = "INC" and [time_worked] < 1 then 1 else [time_worked]Sorry not use to DAX at all. Use to doing these in DOMO.
- Creature3 years agoFrequent Visitor
Greg_Deckler sorry to be annoying, just trying to get good data lol