Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Check if date from one table lies between two dates from another table

Hi everyone,   i'm quite new to power BI and have some troubles understanding how DAX works..    I think my problem is quite simple: Table Date just includes dates, calender weeks and so on and ...
  • v-yingjl's avatar
    v-yingjl
    5 years ago

    Hi Anonymous ,

    Sorry for replying late. If you just want to check whether the current day(I suppose it as totay() variable) is between the begin date and end date, you can create this measure:

    Check today = 
    IF (
        TODAY () >= SELECTEDVALUE ( 'Table'[GW-Begin] )
            && TODAY () <= SELECTEDVALUE ( 'Table'[GW-end] ),
        "yes",
        "no"
    )

    If it is a date range with a single date table, create this measure:

    Check GW = 
    VAR _max =
        CALCULATE ( MAX ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar' ) )
    VAR _min =
        CALCULATE ( MIN ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar' ) )
    RETURN
        IF (
            _min >= SELECTEDVALUE ( 'Table'[GW-Begin] )
                && _max <= SELECTEDVALUE ( 'Table'[GW-end] ),
            "yes",
            "no"
        )

     

    Attached a sample file in the below, hopes to help you.

     

    Best Regards,
    Yingjie Li

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