Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

What is this code doing and is there a way to display the result without typing in Power Query

Hello everyone, i have a question. I am taking over a project from another developer and i dont quite understand what is this code doing even after referring to the https://docs.microsoft.com/en-us/powerquery-m/date-functions

 

Therefore, I also want to find out is there a way to display this result without typing into the power query editor. Thanks. 

 

#"Filtered Rows3" = Table.SelectRows(#"Filtered Rows1", each [Transaction Date] <= Date.EndOfWeek(Date.AddWeeks(Date.From(DateTime.LocalNow()), -1))),

 

Javierphang_0-1643086324390.png

 

1 ACCEPTED SOLUTION

Hi @Anonymous,

In fact, these values aren't static values strings and they are dynamic calculation results based on M query/DAX functions. You cannot directly typing function string in the filter panel.
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@Anonymous , filter data a week before

Date.From(DateTime.LocalNow()) // today date 

 

Date.AddWeeks(Date.From(DateTime.LocalNow()), -1) // a week before date

 

end of last week

Date.EndOfWeek(Date.AddWeeks(Date.From(DateTime.LocalNow()), -1))

 

so filtering date before last week end date.

 

You can do that dax, but you can create a flag column or a new tbale

 

 

Monday last week end date

Week End date = [Transaction Date]+ 7-1*WEEKDAY([Transaction Date],2) -7

Sunday last week end date

Week End date = [Transaction Date]+ 7-1*WEEKDAY([Transaction Date],1) -7

 

a new column

if([Transaction Date] <= [Week End date],1,0)

Anonymous
Not applicable

Thanks for the explanation.

Is there a way where can i can show the result visually instead of keying them into the power query? Thanks!

@Anonymous , not very clear, You can have last week end date in dax like

 

Monday last week end date

Week End date = [Transaction Date]+ 7-1*WEEKDAY([Transaction Date],2) -7

Sunday last week end date

Week End date = [Transaction Date]+ 7-1*WEEKDAY([Transaction Date],1) -7

 

 

power query like

Date.EndOfWeek(Date.AddWeeks(Date.From(DateTime.LocalNow()), -1)

 

what you mean by visually ?

Anonymous
Not applicable

Javierphang_0-1643086324390.png

Like this, where i dont really need to type in the advanced editor.

Hi @Anonymous,

In fact, these values aren't static values strings and they are dynamic calculation results based on M query/DAX functions. You cannot directly typing function string in the filter panel.
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

Understood, Thanks!

Hi @Anonymous,

I'm glad to hear this helps. 🙂

BTW, power bi can only extract text values from this input panel so all the inputted 'characters' or 'function names' will be forced escapes /recognized as text values. That is the reason we had to do custom with the filter function itself instead of operating on the 'quick action' panel.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.