Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (11.1k points)

I am having a table which consists of user IDs and SecondsToOrder and i am using Multiple IF Statements

UserID      SecondsToOrder
00001       2320
00002       13
00003       389
00004       95
...         ...

Then I have added a new calculated column MinutesRounded and table looks like this

UserID      SecondsToOrder   MinutesRounded
00001       2320             38
00002       13               0
00003       389              12
00004       95               1
...         ...              ...

Then i added a column Lenght which looks like this

UserID      SecondsToOrder   MinutesRounded    Lenght
00001       2320             38               > 15 minutes
00002       13               0                < 1 minute 
00003       389              12               < 15 minutes 
00004       95               1                < 1 minute  

... ... ... ...  

I have used this DAX Statement

Lenght = IF([MinutesRounded]<1,"< 1 minute",IF([MinutesRounded]<15,"<15 minutes", "> 15 minutes")) 

And i got this syntax error

The syntax for '"< 1 minute"' is incorrect. (DAX(IF([MinutesRounded]<1."< 1 minute",IF([MinutesRounded]<15."<15 minutes", "> 15 minutes")))). 

 

1 Answer

0 votes
by (22.5k points)

Use switch statement

=
SWITCH (
    TRUE (),
    [MinutesRounded] < 1, "< 1 minute",
    [MinutesRounded] < 15, "<15 minutes",
    "> 15 minutes"
)

If you want to learn more about Power BI, then read the Power BI Tutorial. Also, enroll in Power BI Training to become proficient in this BI tool.    

Related questions

0 votes
1 answer
asked Nov 4, 2020 in BI by Sudhir_1997 (55.6k points)
0 votes
1 answer
asked Nov 30, 2020 in BI by Chris (11.1k points)
0 votes
1 answer
0 votes
1 answer
asked Feb 21, 2021 in BI by Chris (11.1k points)
0 votes
1 answer

Browse Categories

...