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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Joorge_C
Resolver II
Resolver II

PBI Power Query M Code ---- Filter 1st Date Capture of the Month

Hello All, Thanks in advance for your help and time.

 

I need to capture 1st Ocurrance only of Data with the DATE in a Month, I had a filter for less than 2nd Week of Month and less than 6th Day of month, to be able to get to that initial Snapshot in case there was a second close by entry.

 

The issue I have now, the entry was done on day 10, week 3. 

So I need to adjust my Filter to Capture the 1st Instance of Date in the Data by Month.

Any Ideas?

 

 
 

date filter.png

1 ACCEPTED SOLUTION

Hi @Joorge_C

 

I made a sample table as below:

Annotation 2020-06-02 095017.png

Then take the steps as below:

In query editor>add column>custom column,put the below M code inside:

Annotation 2020-06-02 095158.png

 

Then right click on the column "Month", choose "group by "funtion and make the selection as below:

Annotation 2020-06-02 095400.pngAnnotation 2020-06-02 095526.png

 

Finally you will see:

Annotation 2020-06-02 095731.png

For the related .pbix file,pls click here.(You can also check the details in "advanced editor")

 

 

 
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

View solution in original post

3 REPLIES 3
v-kelly-msft
Community Support
Community Support

Hi @Joorge_C

 

If I didnt understand wrong that you wanna create a slicer and show the 1st date of the Month,right?

If so,create a calculated column as below:

 

Column = MINX(FILTER('Table',MONTH('Table'[Date])=MONTH(EARLIER('Table'[Date]))),'Table'[Date])

 

Finally you will see:

Annotation 2020-06-01 112249.png

For the related .pbix file, pls click here.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

Hi @v-kelly-msft , Thanks for your inputs.

No Filters. This is on the M Code on the Import of Data

 

This is in the import of the data in power query, there is a daily snapshot in the data and I need to grab the first occurance of date in the month by month and filter out the rest of the Dates. The data is huge so this needs to be done in Query to the PBI is not impacted by having data in teh back end that is not needed.

Hi @Joorge_C

 

I made a sample table as below:

Annotation 2020-06-02 095017.png

Then take the steps as below:

In query editor>add column>custom column,put the below M code inside:

Annotation 2020-06-02 095158.png

 

Then right click on the column "Month", choose "group by "funtion and make the selection as below:

Annotation 2020-06-02 095400.pngAnnotation 2020-06-02 095526.png

 

Finally you will see:

Annotation 2020-06-02 095731.png

For the related .pbix file,pls click here.(You can also check the details in "advanced editor")

 

 

 
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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