Forum Discussion

West2345's avatar
West2345
New Member
3 years ago

Too few arguments were passed to the IF function. The minimum argument count for the function is 2.

Hi, I am new to Power Bi and I am struggling with DAX. I have this function in order to print out Seasons but it is giving me an error. How can I fix this?

 

Seasons =

IF(OR(Holiday[Month of travel) ==12,

IF (Holiday[Month of travel] <3, "Winter", IF(Holiday[Month of travel] <6, "Spring",

IF (Holding [Month of travel]<9, "Summer", "Autumn")))))

2 Replies

  • hi West2345 

    try like:

    Seasons =
    SWITCH(
        TRUE(),
        Holiday[Month of travel] IN {12,1, 2}, "Winter",
        Holiday[Month of travel] IN {3, 4, 5}, "Spring",
        Holiday[Month of travel] IN {6, 7, 8}, "Summer",
        "Autumn"  
    )
  • ppm1's avatar
    ppm1
    Icon for Solution Sage rankSolution Sage

    It is possible to do that with nested IF, but you may want to learn about the SWITCH function (and it's use with TRUE() for these scenarios). Fixed IF also shown.

     

    Seasons =
    SWITCH (
        TRUE (),
        Holiday[Month of travel] IN { 1, 2, 12 }, "Winter",
        Holiday[Month of travel] IN { 3, 4, 5 }, "Spring",
        Holiday[Month of travel] IN { 6, 7, 8 }, "Summer",
        "Autumn"
    )
    
    Seasons =
    IF (
        OR ( Holiday[Month of travel] = 12, Holiday[Month of travel] < 3 ),
        "Winter",
        IF (
            Holiday[Month of travel] < 6,
            "Spring",
            IF ( Holding[Month of travel] < 9, "Summer", "Autumn" )
        )
    )

     

     

    Pat