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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Monica_far_blue
New Member

Power BI sumarize and filter several times a table

Hello everyone,

 

I have a table with a specific column called Column.Code.

 

Column.Code
A-B-BLUE
A-B-BLUE
A-B-BLUE
A-B-BLUE
A-B-ORANGE
A-B-ORANGE
A-B-ORANGE
A-B-ORANGE
A-B-ORANGE
A-B-ORANGE
A-B-ORANGE
A-B-ORANGE
A-B-ORANGE
A-B-ORANGE
A-B-WHITE
A-B-WHITE
A-B-WHITE
A-B-WHITE
A-C-BLUE
A-C-BLUE
A-C-BLUE
A-C-BLUE
A-C-WHITE
A-C-WHITE
A-C-WHITE
A-C-WHITE
A-C-WHITE
A-D-BLUE
A-D-BLUE
A-E-BLACK
A-E-BLACK
A-E-BLACK
A-E-BLACK

 

I would like to count the number of times that the codes are repeated. After this first step, I want only to use the codes repeated at least 4 times.

To get this, I created a measure with the following code:

 

 

 

 

VAR Table_SUM = SUMARIZE('Table',
                     [Column.Code],
                     "Count", COUNTROWS('Table'))

RETURN COUNTROWS(FILTER(Table_SUM, [Count]>3))

 

 

 

 

In my example, I wouldn't consider the code "A-D-BLUE" for the next step (since it is only repeated twice).

 

Column.CodeCounts First Two Letters
A-B-ORANGE10 A-B
A-C-WHITE5 A-C
A-B-WHITE4 A-B
A-C-BLUE4 A-C
A-B-BLUE4 A-B
A-E-BLACK4 A-E
A-D-BLUE2 A-D


The next step, and the result I am looking for, it would be counting the number of times that the first two letters of the code are repeated: A-B, A-C, and A-E (please note that A-D did not meet the previous criterion)

 

First Two Letters
A-B
A-B
A-B
A-C
A-C
A-D
A-E

 

The final result should be something like this (ignore the final column "demo", it is only to show you the logic behind the solution I am looking for):

 

number of times the first two letters are repeated:Count"demo"
One1A-E
Two2A-C
Three or more1A-B

 

I would appreciate if someone could shed any light on this question.

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Monica_far_blue Is this what you are looking for? See PBIX attached below signature.

Table 2 = 
    VAR __Summarize1 = SUMMARIZE('Table', [Column.Code], "__Count", COUNTROWS('Table'))
    VAR __Filter1 = FILTER(__Summarize1, [__Count] > 3)
    VAR __AddColumns1 = ADDCOLUMNS(__Filter1, "__Code", LEFT([Column.Code],3), "__Color",MID([Column.Code],4,LEN([Column.Code])-3))
    VAR __Summarize2 = SUMMARIZE(__AddColumns1, [__Code], "__Count", COUNTROWS(FILTER(__AddColumns1, [__Code] = EARLIER([__Code]))))
RETURN
    __Summarize2

 



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

2 REPLIES 2
Monica_far_blue
New Member

This was exactly what I was looking for!!!! Thank you very much!! You did it really quick, amazing!!!

Greg_Deckler
Community Champion
Community Champion

@Monica_far_blue Is this what you are looking for? See PBIX attached below signature.

Table 2 = 
    VAR __Summarize1 = SUMMARIZE('Table', [Column.Code], "__Count", COUNTROWS('Table'))
    VAR __Filter1 = FILTER(__Summarize1, [__Count] > 3)
    VAR __AddColumns1 = ADDCOLUMNS(__Filter1, "__Code", LEFT([Column.Code],3), "__Color",MID([Column.Code],4,LEN([Column.Code])-3))
    VAR __Summarize2 = SUMMARIZE(__AddColumns1, [__Code], "__Count", COUNTROWS(FILTER(__AddColumns1, [__Code] = EARLIER([__Code]))))
RETURN
    __Summarize2

 



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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.