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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

IF ELSE for DATE

Hello, i have formula below and i would like to modify them into a new tagging.. 

 

 

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"
)))

 

 

My desired output:

 

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

Right now, the data is 

 

Laedays_0-1634205502069.png

So for the DESIRED OUTPUT:

 

SSDComponent Code
Backlog4180
Today2326
Future 36740

 

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You can create a new table as follows, this table does not create any relationship with the main table.

7.png8.png

 

In my main table, today in your formula I took the fixed date October 20, 2021.

9.png

 

Now create the measure as

Component Code = 
SWITCH (
    MAX ( 'Table'[SSD] ),
    "Backlog",
        CALCULATE (
            SUM ( 'Open Orders_BOM'[Component Code] ),
            FILTER ( 'Open Orders_BOM', [SSD] IN { "Backlog", "N5D", "Today" } )
        ),
    "Today",
        CALCULATE (
            SUM ( 'Open Orders_BOM'[Component Code] ),
            FILTER ( 'Open Orders_BOM', [SSD] IN { "Backlog", "Today" } )
        ),
    "Future",
        CALCULATE (
            SUM ( 'Open Orders_BOM'[Component Code] ),
            FILTER ( 'Open Orders_BOM', [SSD] = "Future" )
        )
)

10.png

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

5 REPLIES 5
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You can create a new table as follows, this table does not create any relationship with the main table.

7.png8.png

 

In my main table, today in your formula I took the fixed date October 20, 2021.

9.png

 

Now create the measure as

Component Code = 
SWITCH (
    MAX ( 'Table'[SSD] ),
    "Backlog",
        CALCULATE (
            SUM ( 'Open Orders_BOM'[Component Code] ),
            FILTER ( 'Open Orders_BOM', [SSD] IN { "Backlog", "N5D", "Today" } )
        ),
    "Today",
        CALCULATE (
            SUM ( 'Open Orders_BOM'[Component Code] ),
            FILTER ( 'Open Orders_BOM', [SSD] IN { "Backlog", "Today" } )
        ),
    "Future",
        CALCULATE (
            SUM ( 'Open Orders_BOM'[Component Code] ),
            FILTER ( 'Open Orders_BOM', [SSD] = "Future" )
        )
)

10.png

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Anonymous
Not applicable

@v-stephen-msft you are a genius. thank you!

selimovd
Super User
Super User

Hey @Anonymous ,

 

do you want to add a new measure or a new calculated column?

The code you posted would only work with a calculated column.

 

Where exactly are you struggling or what is your question?

 

Best regards

Denis

Anonymous
Not applicable

@selimovd i would like to add it as a calculated column if that is the only way it works.

 

So for my DESIRED OUTPUT:

 

SSDComponent Code
Backlog4180
Today2326
Future 36740

 

@Anonymous if you want a new column that in categorizing into Backlog, Today, N5D and Future depending on the value of the column 'Open Orders_BOM'[SCHEDULE_SHIP_DATE], then that's the way to go.

 

Then my question is where are you struggling?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.