Forum Discussion

5000's avatar
5000
New Member
1 year ago
Solved

SWITCH on Conditional DATETIME selection help

I believe I am missing something obvious here.  Looking to select a 'PIT Date' (shown in bottom right), then compare that date to other dates (today, a 'create date', and an 'actual date') in order t...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi, 5000 

    Thanks for Ritaf1983's concern about this issue.

     

    May I ask what your dataset looks like?
    Since you didn't give the dataset for conducting the test, I assumed some data for my own test:

     


    In my tests, your Measure is working fine:


    Maybe you can refer to my Measure for modification:

     

     

    PIT Status2 =
    VAR CurrentPIT =
        IFERROR ( SELECTEDVALUE ( 'Z_Point In Time'[PIT Date], TODAY () ), TODAY () )
    RETURN
        SWITCH (
            TRUE (),
            CurrentPIT = TODAY (), [Order Line Status1],
            [Order Line Status1] = "Open"
                && CurrentPIT > [Create Date], "Open",
            [Order Line Status1] = "Open"
                && CurrentPIT <= [Create Date], "",
            [Order Line Status1] = "Shipped"
                && CurrentPIT > [Actual Date], "Shipped",
            [Order Line Status1] = "Shipped"
                && CurrentPIT <= [Actual Date]
                && CurrentPIT > [Create Date], "Open",
            [Order Line Status1] = "Shipped"
                && CurrentPIT <= [Actual Date]
                && CurrentPIT <= [Create Date], "",
            "NOT"
        )
    

     

     


    I have attached the pbix file below for your reference, I hope it helps.

     

     

    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
    Best Regards,
    Fen Ling,
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.