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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Dynamic Count of Value Combinations That Appear In Previous Rows

Hello PBI Community! I've been trying to work out a way to count how many times a rows combination of values appears in previous rows based on that specific rows entries but I'm hitting a wall...

 

For instance, I have a table that pools the entries from an online referral form, consisting of the referred persons code, the referrer's code, and a hidden field for when I pay the referrer for that referral. What I'd like to do is count how many times the combination of codes has been paid for each row, regardless of whether I've paid that specific referral or not. I made a reference column concatenating the values together hoping that would help ease the process but I've had no luck so far 😞

 

Below is a table of what I have with an added  "Paid Count" column of how I'd imagine the measured column would operate.

 

ReferredReferrerPaid?Concatenated Value

Paid Count

BHEH3TNEW2FALSE

BHEH3TNEW2FALSE

0
KJJK2OJCK3FALSEKJJK2OJCK3FALSE1
KJJK2OJCK3TRUEKJJK2OJCK3TRUE1
MJJD5IHDH4TRUE

MJJD5IHDH4TRUE

2
MJJD5IHDH4TRUEMJJD5IHDH4TRUE2
MGGE1IJJK3FALSE

MGGE1IJJK3FALSE

1
MGGE1IJJK3TRUEMGGE1IJJK3TRUE1
MGGE1IJJK3FALSEMGGE1IJJK3FALSE1

 

All I've managed so far is a column that will identify this number for the row that shows "TRUE" only, leaving all the repeated combinations that are still "FALSE" blank..

 

If anyone has any suggestions I'd love to hear them! Thank you all for your help!

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous Can you paste as text? But essentially:

Column = COUNTROWS(FILTER('Table',[Column]=EARLIER([Column]) && [Column1] = EARLIER([Column1]) && [Some Column] = "TRUE"))

 

Something along those lines.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Just an update to this, I think I was making it harder on myself than it needed to be haha. I ended up using a reference column that marks 1 for those paid and then used an expression like below to sum these values for each code pair/row:

Reference Column = IF( [Column3] = TRUE, 1, 0 )

           

Expression = 

       CALCULATE(

                    SUM( [Reference Column] ) ,

                    FILTER( 'Table', [Column1] = EARLIER( [Column1] ) && [Column2] = EARLIER( [Column2])

     )

 

Thanks again for the help @Greg_Deckler!

Greg_Deckler
Community Champion
Community Champion

@Anonymous Can you paste as text? But essentially:

Column = COUNTROWS(FILTER('Table',[Column]=EARLIER([Column]) && [Column1] = EARLIER([Column1]) && [Some Column] = "TRUE"))

 

Something along those lines.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_DecklerGreg, thanks for your help! Your function does indeed count the amount of code combinations that have been paid, but it's only calulating it for the rows that have been paid. If at all possible, I'd like it to be able to show those same values for the ones that aren't paid as well. Like if Jerry referred Cindy three times but was only paid out for one, I'd like all three rows to show a value of 1, the way the function operates now would show "blank/null" for two of the rows and "1" for only one row. 

 

Retrying Pasting...

Referred   Referrer    Paid?      Concatenated Value     Paid Count
BHEH3,     TNEW2,    FALSE,     BHEH3TNEW2FALSE,     0/NULL
KJJK2,       OJCK3,      FALSE,     KJJK2OJCK3FALSE,         1
KJJK2,       OJCK3,      TRUE,      KJJK2OJCK3TRUE,          1
MJJD5,     IHDH4,      TRUE,      MJJD5IHDH4TRUE,         2
MJJD5,     IHDH4,     TRUE,      MJJD5IHDH4TRUE,          2
MGGE1,      IJJK3,     FALSE,     MGGE1IJJK3FALSE,          1
MGGE1,      IJJK3,     TRUE,      MGGE1IJJK3TRUE,           1
MGGE1,      IJJK3,     FALSE,     MGGE1IJJK3FALSE,          1

 

No Format:

Referred Referrer Paid? Concatenated Value Paid Count
BHEH3 TNEW2 FALSE BHEH3TNEW2FALSE 0
KJJK2 OJCK3 FALSE KJJK2OJCK3FALSE 1
KJJK2 OJCK3 TRUE KJJK2OJCK3TRUE 1
MJJD5 IHDH4 TRUE MJJD5IHDH4TRUE 2
MJJD5 IHDH4 TRUE MJJD5IHDH4TRUE 2
MGGE1 IJJK3 FALSE MGGE1IJJK3FALSE 1
MGGE1 IJJK3 TRUE MGGE1IJJK3TRUE 1
MGGE1 IJJK3 FALSE MGGE1IJJK3FALSE 1

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.