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
UsePowerBI
Post Prodigy
Post Prodigy

How can I filter an array based on the nth value?

Hello

 

From the date-sorted array:

 

ID1, K, 01/01/20

ID1, R, 02/02/20

ID1, T, 02/03/20

ID1, R, 03/04/20

ID1, S, 03/05/20

ID1, T, 03/06/20

...

 

I want to return an array that is as the above but only the part below the last "R".

 

I.e.:

ID1, S, 03/05/20

ID1, T, 03/06/20

 

Is that possible?

 

Thanks!

1 ACCEPTED SOLUTION
v-xiaoyan-msft
Community Support
Community Support

Hi@UsePowerBI,

 

I make a simple sample,you can create the corresponding time column according to the Test column then find whether there are items in the Test column that meet the criteria of the R column.

try measure like :

 

Measure = VAR Q1= CALCULATE(MAX('Table'[date]),FILTER(ALL('Table'),'Table'[r]<>BLANK())) VAR Q2= CALCULATE(MAX('Table'[date]),FILTER(ALL('Table'),MAX('Table'[date])>Q1)) RETURN Q2
 
then you will get :
Screenshot 2021-03-09 .png
 
Here is the demo:
 

Hope it helps.

 

Best Regards,
Caitlyn Yan

 

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

2 REPLIES 2
v-xiaoyan-msft
Community Support
Community Support

Hi@UsePowerBI,

 

I make a simple sample,you can create the corresponding time column according to the Test column then find whether there are items in the Test column that meet the criteria of the R column.

try measure like :

 

Measure = VAR Q1= CALCULATE(MAX('Table'[date]),FILTER(ALL('Table'),'Table'[r]<>BLANK())) VAR Q2= CALCULATE(MAX('Table'[date]),FILTER(ALL('Table'),MAX('Table'[date])>Q1)) RETURN Q2
 
then you will get :
Screenshot 2021-03-09 .png
 
Here is the demo:
 

Hope it helps.

 

Best Regards,
Caitlyn Yan

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.


 

timg
Solution Sage
Solution Sage

 Hi,

Could you clarify what the rule is for including or excluding rows in your array? like should the top 4 rows always be excluded? Or should only the last 2 rows always be included? or is there a date after which records should be included? etc.

Regards,

Tim





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.