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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Brett007
Helper III
Helper III

Count Consecutive Rows by multiple Column Filters

Looking to Calculate the Consecutive Weeks (Rows) at 'Combined Color' filtered by 'Project ID' 

Ideally, it would be a Column that would count how many weeks (Rows) it was at the same 'Combined Color'

 

Brett007_0-1679584984333.png

Expected Result Project ID 344 , Index 4, Combined Color Orange, Count 2

 

PBi File for Troubleshooting issues online.pbix

 

I have figured out a way to calculate consecutive rows, unfortunately, that is as far as I have got thus far.

Combined Color repeats =
VAR _Prev = CALCULATE(MAX(IssuesArchived[Combined Color #]), FILTER(IssuesArchivedAND(AND(EARLIER(IssuesArchived[Index]) -1 = IssuesArchived[Index]IssuesArchived[Program] = EARLIER(IssuesArchived[Program])), IssuesArchived[Project ID] = EARLIER(IssuesArchived[Project ID]))))

RETURN
If(_Prev <> IssuesArchived[Combined Color #],0,1)
1 ACCEPTED SOLUTION
Brett007
Helper III
Helper III

Solved by this Calculated Column:

Column (Aldert) =

var rowPickup = CALCULATE(MAX(IssuesArchived[Index]),
    FILTER('IssuesArchived',
        IssuesArchived[Project ID] = EARLIER(IssuesArchived[Project ID])
        && IssuesArchived[Index] < EARLIER(IssuesArchived[Index])
        && IssuesArchived[Combined Color] <> EARLIER(IssuesArchived[Combined Color])))
return
    IF(rowPickup = BLANK(),
        COUNTROWS(FILTER(IssuesArchived,
            IssuesArchived[Project ID] = EARLIER(IssuesArchived[Project ID])
            && IssuesArchived[Index] < EARLIER(IssuesArchived[Index]))) + 1 ,
       IssuesArchived[Index] - rowPickup)
 

View solution in original post

1 REPLY 1
Brett007
Helper III
Helper III

Solved by this Calculated Column:

Column (Aldert) =

var rowPickup = CALCULATE(MAX(IssuesArchived[Index]),
    FILTER('IssuesArchived',
        IssuesArchived[Project ID] = EARLIER(IssuesArchived[Project ID])
        && IssuesArchived[Index] < EARLIER(IssuesArchived[Index])
        && IssuesArchived[Combined Color] <> EARLIER(IssuesArchived[Combined Color])))
return
    IF(rowPickup = BLANK(),
        COUNTROWS(FILTER(IssuesArchived,
            IssuesArchived[Project ID] = EARLIER(IssuesArchived[Project ID])
            && IssuesArchived[Index] < EARLIER(IssuesArchived[Index]))) + 1 ,
       IssuesArchived[Index] - rowPickup)
 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.