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
adamnimmo
Helper I
Helper I

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 @adamnimmo ,

 

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 @adamnimmo ,

 

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.

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

parry2k
Super User
Super User

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

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

 

Example.xlsx 

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

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