Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

SQL function like behavior using DAX

This may have already been addressed, however, I am still working on my DAX education so I’m sure I just don’t understand enough to realize I passed over the information. Thanks in advance for any he...
  • v-juanli-msft's avatar
    v-juanli-msft
    7 years ago

    Hi Anonymous

    According to the rule, it seems the line should be "current" instead of "future", 2018/10/21 is the Sunday of this week

    ID Ship Date Quote Date Future
    20021373QT 10/21/2018 10/19/2018 1

     

    when you select a date range (date column from a disconnected table) 

    Create measures in the table

    min = MIN(calendar[date])

    weeknum-Ship Date = WEEKNUM(MAX([Ship Date]),2) weeknum-Quote Date = WEEKNUM(MAX([Quote Date]),2) currentweek = WEEKNUM([min]) state = SWITCH ( TRUE (), [weeknum-Ship Date] = [currentweek] && [weeknum-Quote Date] = [currentweek], "current", [weeknum-Ship Date] = [currentweek] && [weeknum-Quote Date] < [currentweek], "prior", [weeknum-Ship Date] > [currentweek] && [weeknum-Quote Date] = [currentweek], "future" )

     

     

    Best Regards

    Maggie