Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Create a custom column with a new date based off another's column date

Hello,   I'm new to powerBI so I think this should be easy. I want to create a custom column based off another column's date. If the original column is before today I want the custom column to sho...
  • Icey's avatar
    Icey
    6 years ago

    Hi Anonymous ,

     

    Power Query Editor is used to connect to one or many data sources, to shape and transform the data to meet your needs. Then you can load that model into Power BI Desktop to create reports.

    For Power Query Editor, you can refer to this document: https://docs.microsoft.com/en-us/power-bi/desktop-query-overview.

    For Power BI Desktop, you can refer to this document: https://docs.microsoft.com/en-us/power-bi/desktop-what-is-desktop.

     

    Then, let's answer your question.

     

    If you want to create a custom column in Power Query Editor, you can try this:

    1. Add Column -> Custom Column.

     

     

    2. Type the M expression:

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

     

    3. Then you can get a custom column that meets your requirements.

     

    If you want to create a Calculated Column in Power BI Desktop. Try this:

    1. Modeling -> New Column.

    2. Type the DAX expression:

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

     

    For details, please check the attached PBIX file.

     

     

    Best Regards,

    Icey

     

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