Forum Discussion

MP-iCONN's avatar
MP-iCONN
Icon for Resolver I rankResolver I
5 years ago
Solved

Power Query for a unique date range

Trying to get the current first day of the month minus 1 year and then current first day of the month plus 1 year for a date range using to customize my SQL query for Power BI.   Any help will be g...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi  MP-iCONN ,

    Here are the steps you can follow:

    1. Add Column – Custom Column.

    [date] >= #date(Date.Year(DateTime.LocalNow()) -1 ,  Date.Month(Date.StartOfMonth(DateTime.LocalNow())), 1)
    
    and
    
    [date] <=#date(Date.Year(DateTime.LocalNow()) +1 ,  Date.Month(Date.StartOfMonth(DateTime.LocalNow())), 1)

    2. Click [Flag] and select True.

    3. Result.

    The data left is 2020.11.1-2022.11.1

     

    Best Regards,

    Liu Yang

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