Forum Discussion

Jo74's avatar
Jo74
Regular Visitor
1 year ago
Solved

Powerquery add column If date in another column is more than a year ago

Hi all I am fairly new to Power Query and need some help please.  I have a column with a created date and if it is more than a year old the calculation is based on another column.   So If created ...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Jo74 ,

    That is something that can be done using Microsoft Power Query  Formula language(informally called as M language).
    Follow this documentation to learn more about M query
    Power Query M formula language reference - PowerQuery M | Microsoft Learn

    As mentioned by OwenAuger, the provided M query will help you in creating a new column that you want.

    Please reach out to us if you have any further quries related to the provided M query or in power query in general
    Dont forget to mark the helpful solution so as to help other community members

    If my response(s) assisted you in any way, don't forget to give "Kudos"

    Thanks and Regards



  • OwenAuger's avatar
    OwenAuger
    1 year ago

    Thanks for trying this Jo.

    Just to clarify, my sample M code was intended to illustrate the steps that should be added to the query after the step that produces your existing table.

     

    The Source step in my sample should be replaced with whatever steps produced your initial table, then the  Date Threshold and Added New Column steps added after this.

    You could add these steps either in the Advanced Editor or by adding steps and entering code in the formula bar.

     

    Here is a short recording of how I would apply this starting from the table you just posted, using the formula bar to enter the steps, and I have attached a PBIX with this query: