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
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
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.