Forum Discussion

powerbiwork's avatar
powerbiwork
Helper I
5 years ago
Solved

Custom Column Query

Hi, 

I am having issues for the following. Basically Im trying to pull a live currency rate but the currency is only pulled to todays date. In close I have future dates. I want to have a custom column that if the close date is future date then just use todays date. 

 

Thanks so much in advance

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi powerbiwork ,

     

    You can try to create your custom column as

    if [Date]<=Date.From( DateTime.LocalNow())
    then [Date] else Date.From( DateTime.LocalNow())

     

     

    Creating a calculated column is easier.

    Column = IF([Date]<=TODAY(),[Date],TODAY())

     

     

    You can check more details from here.

     

     

    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.

     

     

7 Replies

  • lkalawski's avatar
    lkalawski
    Resident Rockstar

    Hi powerbiwork ,

    I noticed that you forget to add brackets before "else". Please try to add it. 

     

    Proud to be a Super User.
    If I helped, please accept the solution and give kudos
    Linkedin

     

     
    • powerbiwork's avatar
      powerbiwork
      Helper I

      Ah, got it thank you. But now I seem to have another error 😞 

       

      • lkalawski's avatar
        lkalawski
        Resident Rockstar

        powerbiwork 

        Before you add custom column, please check the format of CloseDate - should be "Date".

         

        Proud to be a Super User.
        If I helped, please accept the solution and give kudos
        Linkedin

         

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi powerbiwork ,

     

    You can try to create your custom column as

    if [Date]<=Date.From( DateTime.LocalNow())
    then [Date] else Date.From( DateTime.LocalNow())

     

     

    Creating a calculated column is easier.

    Column = IF([Date]<=TODAY(),[Date],TODAY())

     

     

    You can check more details from here.

     

     

    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.

     

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi powerbiwork ,

    Could you tell me if your problem has been solved?
    If it is, kindly Accept it as the solution. More people will benefit from it.
    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.


    Best Regards,
    Stephen Tao