Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

How to use date function in statment

Hello,   im trying to write if statment with date function, however im getting error . the porpose for the statment to give and date before "31/12/2009" as number 0 then give following date. below ...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

     

    What data type is your [Sales-DATE]?

    If your [Sales-DATE] is text type, please see the following calculated column.

     

    Base column =
    VAR _month =
        RIGHT ( LEFT ( [Sales-DATE], 5 ), 2 )
    VAR _day =
        LEFT ( [Sales-DATE], 2 )
    VAR _year =
        RIGHT ( [Sales-DATE], 4 )
    RETURN
        IF (
            [Sales-DATE] <> "Null",
            IF ( DATE ( _year, _month, _day ) <= DATE ( 2009, 12, 31 ), 0, [Year.Base] )
        )
    

     

     

    Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.

     

    You can check the details in the attachment.

     

    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.