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
power2
Frequent Visitor

180 days loop

Hey everyone,

 

I have a table with thosuands of parts that are received into our system. 

Let's say Column A is the ItemID which is the part number and Column B is the Date that was received.

 

My goal is to check if a given part has entered into our system more than 5 times in a given 180 days period. So, at this point, I made something that works but it only checks for the last 180 days from today. I want to build something that can check for any 180 days for 5 batches received.

 

So, let's say if one part was received for 5 times between Jan 1st and July 1st for 5 times back in 2020, I want to flag that part.

Here is my current code with the 180 days from today thing.


#"Filtered Rows1" = Table.SelectRows(#"Filtered Rows", each [CREATEDDATETIME] > DateTime.LocalNow() - #duration(180, 0, 0, 0)),
#"Grouped Rows" = Table.Group(#"Filtered Rows1", {"ItemId", "ItemName"}, {{"Count", each Table.RowCount(_), Int64.Type}}),
#"Filtered Rows2" = Table.SelectRows(#"Grouped Rows", each [Count] >= 5)

1 ACCEPTED SOLUTION

@power2 I would think something like this:

Greg_Deckler_0-1709852439229.png

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@power2 So, I would create a Parameter and then replace DateTime.LocalNow() with the name of that Parameter.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 
Thanks for the advise. In this case, how would that parameter look like? Can you be a little more specific?

@power2 I would think something like this:

Greg_Deckler_0-1709852439229.png

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 
Thanks. I will give this a try.

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.