Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

multiple ifs

Hi, i have multiple conditions, how is this doable in power bi?

 

IF
([SCHEDULE_SHIP_DATE] < TODAY() OR [SCHEDULE_SHIP_DATE] < TODAY() + 2)

THEN 'Today'

 

ELSEIF ([SCHEDULE_SHIP_DATE] < TODAY() OR
            [SCHEDULE_SHIP_DATE] < TODAY() + 2 OR
            [SCHEDULE_SHIP_DATE] < TODAY() + 6)

 

THEN 'N5D'

 

ELSEIF ([SCHEDULE_SHIP_DATE] < TODAY() + 13)

 

THEN 'N2W'

 

END

4 REPLIES 4
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

You could try SWITCH() function.

https://docs.microsoft.com/en-us/dax/switch-function-dax 

However, the second condition look wired.

([SCHEDULE_SHIP_DATE] < TODAY() OR [SCHEDULE_SHIP_DATE] < TODAY() + 2) could be both "Today" and "N5D"?

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
Samarth_18
Community Champion
Community Champion

Hi @Anonymous ,

 

You can use below code:-

 

column =
IF (
    OR ( [SCHEDULE_SHIP_DATE] < TODAY (), [SCHEDULE_SHIP_DATE] < TODAY () + 2 ),
    "Today",
    IF (
        OR (
            [SCHEDULE_SHIP_DATE] < TODAY (),
            OR (
                [SCHEDULE_SHIP_DATE]
                    < ( TODAY () + 2 ),
                [SCHEDULE_SHIP_DATE]
                    < ( TODAY () + 6 )
            )
        ),
        "N5D",
        IF ( [SCHEDULE_SHIP_DATE] < ( TODAY () + 13 ), "N2W" )
    )
)

 

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

hi @Samarth_18 the formula you suggested seems to not be working on the output i desire.

 

this formula:

SSD = IF(
    'Open Orders_BOM'[SCHEDULE_SHIP_DATE] < TODAY(),
    "Backlog",
    IF('Open Orders_BOM'[SCHEDULE_SHIP_DATE] < TODAY() + 2,
    "Today",

 

    IF('Open Orders_BOM'[SCHEDULE_SHIP_DATE]< TODAY() + 6,
    "N5D",
    "Future"
)))
 

 is actually the reference to be used, i want to modify that formula into a new classification:

 

New Column (DESIRED OUTPUT):


N5D will cover all "Backlog" , "N5D", "Today"
Today will cover "Backlog","Today"
Future will be "N2W"

 

 

For your first condition i.e. N5D will cover all "Backlog" , "N5D", "Today", if SSD = N5D then  it will show N5D but it will show N5D for backlog and today as well since we have applied OR condition. N5D and Today cant go in parellel in such case. Could you please check if we are missing any other condition?

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.