Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Count Column by Group and filter Part 2.

I am posting a new thread because when I reply with a question about a possible solution, it is removed for Spam. AlexisOlson    I need to know how many times a project goes in and out the " Tech ...
  • AlexisOlson's avatar
    AlexisOlson
    4 years ago

    Ah, I understand what you mean now.

     

    This requires rather different logic we need to incorporate the concept of adjacent rows using the index.

     

    Try this:

    New Many =
    VAR _CurrPID   = 'Table'[Project ID]
    VAR _CurrIndex = 'Table'[Index]
    VAR _CurrName  = 'Table'[Stage_Name]
    VAR _SubTable_ =
        FILTER (
            'Table',
            'Table'[Project ID] = _CurrPID
                && 'Table'[Index] >= _CurrIndex
                && 'Table'[Stage_Name] = "Tech Review"
        )
    RETURN
        COUNTROWS (
            FILTER (
                _SubTable_,
                VAR _NextName =
                    LOOKUPVALUE (
                        'Table'[Stage_Name],
                        'Table'[Project ID], _CurrPID,
                        'Table'[Index], 'Table'[Index] + 1
                    )
                RETURN
                    _CurrName = "Tech Review" && _NextName <> "Tech Review"
            )
        )