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
narendra1
Helper I
Helper I

select rows from same period previous month

 Hi All,

 

i want help in pulling rows from table which have date column, in the date column it has values from both 2016 and 2017.

now i want to pull particular records which fall in YTD and same period in 2016.

 

i am working in power bi query editor.

 

Capture.PNG

 

from there i want to pull values only upto 01-09-2016.

 

Any help most appreciable.

Thanks in advance.

1 ACCEPTED SOLUTION

@narendra1,

You can add the following code in the Advanced Editor of your query.

#"Filtered Rows" = Table.SelectRows(#"Changed Type1", each Date.Year([DateColumn]) = Date.Year(DateTime.LocalNow())-1 and Date.Month([DateColumn]) <= Date.Month(DateTime.LocalNow()) or Date.Year([DateColumn]) = Date.Year(DateTime.LocalNow()) and Date.Month([DateColumn]) <= Date.Month(DateTime.LocalNow()))


You can review the following sample  to get mode details.
1.JPG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yuezhe-msft
Employee
Employee

@narendra1,

Do you want to only select values between January 2016 and September 2016 in Query Editor? If that is the case, you can use custom filter of the date column like the following sample.
2.JPG3.JPG

However, if you want to select values between January 2016 and September 2016 along with these values that between January 2017 and September 2017, you can filter the rows as shown in the sample below.
1.JPG

If the above steps don't help, please describe more details about your requirement, and share the sample data of your table that can be copied and pasted, I will test it in my Power BI Desktop.

Regards,
Lydia


Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Lydia,

 

I highly appriciate your reply and that will work as well.

but my requirement is dynamic, that means for this month "jan 2016 to sep 2016" and "jan 2017 to sep 2017".  when calender moved to october the filter should automatically fetch values "jan 2016 to oct 2016" and "jan 2017 to oct 2017"

 

hope this make sense.

 

Thanks in advance

@narendra1,

You can add the following code in the Advanced Editor of your query.

#"Filtered Rows" = Table.SelectRows(#"Changed Type1", each Date.Year([DateColumn]) = Date.Year(DateTime.LocalNow())-1 and Date.Month([DateColumn]) <= Date.Month(DateTime.LocalNow()) or Date.Year([DateColumn]) = Date.Year(DateTime.LocalNow()) and Date.Month([DateColumn]) <= Date.Month(DateTime.LocalNow()))


You can review the following sample  to get mode details.
1.JPG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi,

 

Thank you very much, it seems it is working for me.

 

Thank you,

Narendra.

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.