Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Need to create a new column with date range

Hello, I am looking for help on how to generate a new column in my data anf the data range is between 11/30/2021 and 2/14/2022 to put the work Peak if it's between those data and Non Peak if it is not between those date.

 

I tried using conditional but it wouldn't work with range. Please help!

  • Anonymous you are adding this in PQ, my solution was adding a column by DAX. if you want a PQ solution then do the following M code:

     

     

    if [Date] >= #date(2021,11,30) and [Date] <= #date(2022,2,14) then "Peak" else "No Peak"

     

     

     

    Follow us on LinkedIn and  to our YouTube channel

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

     

    Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.

     

     

     

4 Replies

  • Anonymous try this new column

     

    New COlumn = 
    IF ( Table[Date] >= DATE ( 2021, 11, 30 ) && Table[Date] <= DATE ( 2022, 2, 14 ), "Peak", "Non Peak" )

     

     

    Follow us on LinkedIn and  to our YouTube channel

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

     

    Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      comes back with errors see attached screen shot also you can see my date column

  • Anonymous you are adding this in PQ, my solution was adding a column by DAX. if you want a PQ solution then do the following M code:

     

     

    if [Date] >= #date(2021,11,30) and [Date] <= #date(2022,2,14) then "Peak" else "No Peak"

     

     

     

    Follow us on LinkedIn and  to our YouTube channel

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

     

    Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.

     

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      That was perfect for PQ thank you!