Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

IF ELSE

do you guys have an idea how to get this formula in Power BI?

 

if [SHIP_DATE]>TODAY()-1 then 'Current' ELSE 'Overdue' end

  • Anonymous's avatar
    Anonymous
    4 years ago

    HI Anonymous 

     

    If you are looking to create a measure , here is the formula:

     

    Date_fltr_measure = IF(max(Max_Grp1[Date])>TODAY()-1,"Current","Ovedue")

     

     

    If you are looking to create calculated column, here is the formula:

     

    Date_fltr_column = IF(Max_Grp1[Date]>TODAY()-1,"Current","Ovedue")

    Thanks

    Raj

2 Replies

  • Hello there Anonymous ! You have two diferent options:

     

    Option 1 =
    var _date = Table[SHIP_DATE]
    var _current = Table[Current]
    var _over = Table[Overdue]
    
    return
    IF(
    _date > DATE( TODAY() -1 ),
    _current ,
    _over )

     

    Or:

     

    Option 2 =
    var _date = Table[SHIP_DATE]
    var _current = Table[Current]
    var _over = Table[Overdue]
    
    return
    SWITCH(
    TRUE(),
    _date > DATE( TODAY() -1 ), _current ,
    _over )

     

    Hope this answer solves your problem!
    If you need any additional help please @ me in your reply.
    If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
    Thanks!

    You can also check out my LinkedIn!

    Best regards,
    Gonçalo Geraldes

  • Anonymous's avatar
    Anonymous
    Not applicable

    HI Anonymous 

     

    If you are looking to create a measure , here is the formula:

     

    Date_fltr_measure = IF(max(Max_Grp1[Date])>TODAY()-1,"Current","Ovedue")

     

     

    If you are looking to create calculated column, here is the formula:

     

    Date_fltr_column = IF(Max_Grp1[Date]>TODAY()-1,"Current","Ovedue")

    Thanks

    Raj