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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Count on first occurrence grouping of qualifying results by location

Morning All, hoping I could get a bit of assistance with a formula I have been stuck on.

I am trying to count the number of instances based on qualifying audit results by location and the latest cluster of instances.

 

 

ResultDatePhaseAuditScoreSortAuditScoreSetInOrderAuditScoreShineAuditScoreSafetyResultDateSoWSortLocationIndexQualifyingQualfyingCountQualifyingResultNeeded
4/22/2020Set In Order44 4Wednesday, April 22, 20202Cell1669197
4/9/2020Set In Order3.53.8 4Thursday, April 9, 20202Cell1670197
3/26/2020Set In Order43.4 4Thursday, March 26, 20202Cell1671197
3/9/2020Set In Order43.4 4Monday, March 9, 20202Cell1672197
2/29/2020Set In Order3.63.4 4Saturday, February 29, 20202Cell1673197
2/28/2020Set In Order3.13.1 4Friday, February 28, 20202Cell1674197
2/10/2020Set In Order3.13.7 4Monday, February 10, 20202Cell1675197
1/31/2020Set In Order42.8 4Friday, January 31, 20202Cell1676 97
1/15/2020Set In Order3.62.8 4Wednesday, January 15, 20202Cell1677 97
12/31/2019Set In Order3.12.8 3.571Tuesday, December 31, 20192Cell1678 97
12/17/2019Set In Order3.63.1 3.8Tuesday, December 17, 20192Cell1679197
12/5/2019Set In Order43.4 4Thursday, December 5, 20192Cell1680197
4/23/2020Sort3.5  3.6Thursday, April 23, 20201Cell2715153
4/23/2020Sort3.1  3.8Thursday, April 23, 20201Cell2716153
4/22/2020Sort3.5  3.6Wednesday, April 22, 20201Cell2717153
4/8/2020Sort2.7  3.2Wednesday, April 8, 20201Cell2718 53
3/26/2020Sort2.3  2.93Thursday, March 26, 20201Cell2719 53
3/11/2020Sort3.1  3.4Wednesday, March 11, 20201Cell2720153
2/24/2020Sort3.6  4Monday, February 24, 20201Cell2721153
1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Create two columns like so:

Column 1 = 
VAR thislocation = Sheet1[Location]
VAR FirstLessThan3Index =
    CALCULATE (
        MIN ( Sheet1[Index] ),
        FILTER ( ALLEXCEPT ( Sheet1, Sheet1[Location] ), [Qualifying] = BLANK () )
    )
RETURN
    IF (
        FirstLessThan3Index > Sheet1[Index]
            && Sheet1[Location] = thislocation,
        1,
        0
    )
Column 2 = 
VAR thislocation = Sheet1[Location]
RETURN
    SUMX ( FILTER ( Sheet1, Sheet1[Location] = thislocation ), [Column 1] )

column2.PNG

 

BTW, .pbix file attached.

 

 

Best Regards,

Icey

 

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

7 REPLIES 7
Syndicate_Admin
Administrator
Administrator

Hi @adamnimmo ,

Create two columns like this:

Column 1 = 
VAR thislocation = Sheet1[Location]
VAR FirstLessThan3Index =
    CALCULATE (
        MIN ( Sheet1[Index] ),
        FILTER ( ALLEXCEPT ( Sheet1, Sheet1[Location] ), [Qualifying] = BLANK () )
    )
RETURN
    IF (
        FirstLessThan3Index > Sheet1[Index]
            && Sheet1[Location] = thislocation,
        1,
        0
    )
Column 2 = 
VAR thislocation = Sheet1[Location]
RETURN
    SUMX ( FILTER ( Sheet1, Sheet1[Location] = thislocation ), [Column 1] )

column2.PNG

BTW, attached .pbix file.

Best regards

Icey

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

Icey
Community Support
Community Support

Hi @Anonymous ,

 

Create two columns like so:

Column 1 = 
VAR thislocation = Sheet1[Location]
VAR FirstLessThan3Index =
    CALCULATE (
        MIN ( Sheet1[Index] ),
        FILTER ( ALLEXCEPT ( Sheet1, Sheet1[Location] ), [Qualifying] = BLANK () )
    )
RETURN
    IF (
        FirstLessThan3Index > Sheet1[Index]
            && Sheet1[Location] = thislocation,
        1,
        0
    )
Column 2 = 
VAR thislocation = Sheet1[Location]
RETURN
    SUMX ( FILTER ( Sheet1, Sheet1[Location] = thislocation ), [Column 1] )

column2.PNG

 

BTW, .pbix file attached.

 

 

Best Regards,

Icey

 

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

Anonymous
Not applicable

@Icey You are brilliant, thank you so much this works perfect.

parry2k
Super User
Super User

@Anonymous data is very hard to understand with all the column connected, can you paste the data in table format or share thru excel and also post the required result.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Sure thing @parry2k  here is the data in an excel table.

 

Example.xlsx 

@Anonymous thanks for the excel file, but whst is the logic to achieve the result?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k  I have two example locations (Cell1 & Cell2) for Cell1 we have 9 qualifying audits (all scores above 3.0) however we also have a gap in concurrent qualyfing audits (Row 9-11). So within this cell example I want to only count the latest group of qualifying audits (7x) since this is the latest concurrent results. The same logic is true for the Cell2 example, I need to only return the latest grouping of concurrent results (3x).

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors