Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Please correct me IF condition

Hello Members, Please let me know is my below IF condition is correct / wrong. I am finding Totalminute between Issue Detection Time & Incident Start  which is generated by name XYZ

 

if [Triggered XYZ] = 1 {
if {
[#" Detection Time (UTC)"] < [#"Incident Start (UTC)"] then
Duration.TotalMinutes([#"Detection Time (UTC)"] - [#"Incident Start (UTC)"])
else
Duration.TotalMinutes([#"Incident Start (UTC)"] - [#"Detection Time (UTC)"])}
}
else
"null"
}

  • Anonymous , Try soething like this

    if [Triggered XYZ] = 1 then
    	if [#" Detection Time (UTC)"] < [#"Incident Start (UTC)"] then
    	Duration.TotalMinutes([#"Detection Time (UTC)"] - [#"Incident Start (UTC)"])
    	else
    	Duration.TotalMinutes([#"Incident Start (UTC)"] - [#"Detection Time (UTC)"])
    else
    	"null"

     

4 Replies

  • Anonymous , Try soething like this

    if [Triggered XYZ] = 1 then
    	if [#" Detection Time (UTC)"] < [#"Incident Start (UTC)"] then
    	Duration.TotalMinutes([#"Detection Time (UTC)"] - [#"Incident Start (UTC)"])
    	else
    	Duration.TotalMinutes([#"Incident Start (UTC)"] - [#"Detection Time (UTC)"])
    else
    	"null"

     

  • AllisonKennedy's avatar
    AllisonKennedy
    Icon for Community Champion rankCommunity Champion
    This looks like something you might want to post in the Power Query forum: https://community.powerbi.com/t5/Power-Query/bd-p/power-bi-services

    What are you trying to find? Please explain your criteria a bit more in 'plain english' so we can help troubleshoot your IF statement, and also please describe your problem. You probably need a 'for each' that seems to be missing.

    Did you try starting with the simple Add Column tab in the ribbon and click the "Conditional Column" button? This will give you the bones/structure to start your formula.
  • AllisonKennedy's avatar
    AllisonKennedy
    Icon for Community Champion rankCommunity Champion
    There is also a button in the Power Query ribbon to calculate duration or total minutes if you select the Detection Time and Incident Start columns, then look in the Add Column tab on the right. They might help you with a start, but I'm not sure where the IF part comes in based on your question.
    • Anonymous's avatar
      Anonymous
      Not applicable

      Triggered BY --- IS having different team - I want to find only XYZ team is triggered by instead of other team.

      and when i did Detection Time - Incident Start some times the value of detection time is more than the incident start. that time i get negative value. because of this i am using if & if