Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Need help to write Multiple IF statements in a Calculated Column

Hi All, New Bee here,   Can you please help me to create a column in Power BI desktop for the below logic which was created in Tableau. I would be using this column (Ageing Category) for creating...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous , ryan_mayu ,

     

    I was able to get the below logic(no syntax issues)  in powerBI for the above logic but how can I include THEN, END, ELSE in my logic below (as these logics are very important to be included to get the exact output). 

    Please help

     

    Ageing Category =
    IF (
        [Category] <> "Future Offboard",
        IF (
            [Category] <> "Unallocated",
         
            SWITCH (
                TRUE (),
                CustomSQL_BenchReport[Delivery_Aging] <= 30, "0-30 Days",
                  CustomSQL_BenchReport[Delivery_Aging]>30 && CustomSQL_BenchReport[Delivery_Aging] <= 60, "31-60 Days",
                 CustomSQL_BenchReport[Delivery_Aging] >60 &&  CustomSQL_BenchReport[Delivery_Aging] <= 90, "61-90 Days",
                 CustomSQL_BenchReport[Delivery_Aging] >90  && CustomSQL_BenchReport[Delivery_Aging] <= 180, "91-180 Days",
                CustomSQL_BenchReport[Delivery_Aging] > 180, ">180 Days"
            ),
       
            SWITCH (
                TRUE (),
                CustomSQL_BenchReport[unallocated_aging] <= 30, "0-30 Days",
                CustomSQL_BenchReport[unallocated_aging] >30 && CustomSQL_BenchReport[unallocated_aging] <= 60, "31-60 Days",
               CustomSQL_BenchReport[unallocated_aging] >60  && CustomSQL_BenchReport[unallocated_aging] <= 90, "61-90 Days",
                CustomSQL_BenchReport[unallocated_aging] >90  && CustomSQL_BenchReport[unallocated_aging] <= 180, "91-180 Days",
                CustomSQL_BenchReport[unallocated_aging] > 180, ">180 Days"
            )
        ),
       
        SWITCH (
            TRUE (),
            CustomSQL_BenchReport[No_of_days] <= 30, "0-30 Days",
             CustomSQL_BenchReport[No_of_days]  >30 && CustomSQL_BenchReport[No_of_days] <= 60, "31-60 Days",
            CustomSQL_BenchReport[No_of_days] >60  && CustomSQL_BenchReport[No_of_days] <= 90, "61-90 Days",
             CustomSQL_BenchReport[No_of_days] >90  && CustomSQL_BenchReport[No_of_days] <= 180, "91-180 Days",
            CustomSQL_BenchReport[No_of_days] >180, ">180 Days"
        )
    )