Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Unable to create a custom column

I am trying to create custom column here which will basically allow me filter data for last 4 days dynamically.

 

this is the query i am using but it is giving me error.

Data type of the modifiedon column is date/time.

  • Anonymous,

     

    Looks like you're missing a closing parenthesis at the end of the expression.

  • Anonymous You can dynamically filter for last 4 days without even creating a calculated column, just paste the below expression at the last line of your M code inside Advance Editor, make sure you include a "," above the Filtered Rows expression like below

     

     

     

    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each 
                           [YourDateColumn] >= Date.From(Date.AddDays(DateTime.LocalNow(),-4)) and 
                           [YourDateColumn] <=Date.From(DateTime.LocalNow()))
    in 
    #"Filtered Rows"

     

     

     

    Did I answer your question? If yes, please mark my post as a solution. 

     

    Thanks,

    Jai

3 Replies

  • Anonymous,

     

    Looks like you're missing a closing parenthesis at the end of the expression.

  • Anonymous You can dynamically filter for last 4 days without even creating a calculated column, just paste the below expression at the last line of your M code inside Advance Editor, make sure you include a "," above the Filtered Rows expression like below

     

     

     

    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each 
                           [YourDateColumn] >= Date.From(Date.AddDays(DateTime.LocalNow(),-4)) and 
                           [YourDateColumn] <=Date.From(DateTime.LocalNow()))
    in 
    #"Filtered Rows"

     

     

     

    Did I answer your question? If yes, please mark my post as a solution. 

     

    Thanks,

    Jai

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

     

    First of all, thanks to DataInsights and Jai-Rathinavel for their attention to this thread and great replies.

     

    I would like to ask if the replies from DataInsights and Jai-Rathinavel have helped you to solve the problem? If so please consider accepting the helpful reply as a solution.

     

    From the error message in your screenshot, it appears that “)” is missing from the end of your formula.
    Here are some similar solved cases for your reference:

    Solved: Date Filtering in Power Query - Microsoft Fabric Community

    Solved: Filter As Per Last N Months, Current Month and Nex... - Microsoft Fabric Community

     

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