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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Combining text of the same column for combinatorial analysis

Hi, I need help with combinatorial Analysis. I'm working on a text recognizing app, and I need help to combine the codified atributes (P, L and F). The first table is the one that the text app recognizes and then we codify it to unite (join) the atributes. The first table has the date as first column, the second is a code of the location and the third one are the main atributes (P, L and F).

 

I've got this table (First Picture) and I need to combine the "Texto_Nomalizado" column and do every posible combination between "P", "L" and "F". The thing is I have to create a frequency table for this combinations. Also it has to be generic because I have more than 500k codes of P, L and F summed up. After the combination, they need to be in the same column like the second table and count them if they both or the three of them exist. The other columns can be deleted if needed. I know it's hard and confusing.

 

The second table was filled randomly.

 

For example, we've got P000001, L000001 and P000001, so we've got something like the third table, with 7 total combinations betweem them.

 

(First Table)

AnibalPb3_0-1620953974236.png

 

(Second Table)

CombinationFrequency  (Count)
#F0000011
#F0000023
#F0000031
#F0000041
#P0000012
#P0000022
#P0000033
#L0000013
#L0000023
#(P000001L000001F000001)1
#(P000002L000002F000002)1
#(P000001L000001F000003)1
#(P000002L000001F000002)1
#(P000003L000002F000002)1
#(P000003L000002F000004)1
#(P000001L000001)2
#(P000001F000001)1
#(L000001F000001)1
#(P000002L000002)1
#(P000002F000002)2
#(L000002F000002)2
#(P000001F000003)1
#(L000001F000003)1
#(L000001F000002)1
#(P000003L000002)2
#(P000003F000002)1
#(P000003F000004)1
#(L000002F000004)1

 

(Third Table)

CombinationFrequency  (Count)
P0000011
L0000011
F0000011
P000001L0000011
P000001F000001

1

L000001F0000011
P000001L000001F0000011

 

Thanks for the help, I know it's complex, I've been working on this for days and I can't figure out how to do it.

1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try to create three table for P L F:

TableP = SELECTCOLUMNS(CALCULATETABLE(VALUES('Table'[Text in code]),FILTER('Table',LEFT('Table'[Text in code])="P")),"P",[Text in code])

TableL = SELECTCOLUMNS(CALCULATETABLE(VALUES('Table'[Text in code]),FILTER('Table',LEFT('Table'[Text in code])="L")),"L",[Text in code])

TableF = SELECTCOLUMNS(CALCULATETABLE(VALUES('Table'[Text in code]),FILTER('Table',LEFT('Table'[Text in code])="F")),"F",[Text in code])

 

Then create the combination table:

 

COMBINE = UNION(TableP,TableL,TableF,SELECTCOLUMNS(ADDCOLUMNS(CROSSJOIN(TableP,TableL),"combine",[P]&[L]),"c",[combine]),SELECTCOLUMNS(ADDCOLUMNS(CROSSJOIN(TableP,TableF),"combine",[P]&[F]),"c",[combine]),SELECTCOLUMNS(ADDCOLUMNS(CROSSJOIN(TableL,TableF),"combine",[L]&[F]),"c",[combine]),SELECTCOLUMNS(ADDCOLUMNS(CROSSJOIN(TableP,TableL,TableF),"combine",[P]&[L]&[F]),"c",[combine]),SELECTCOLUMNS(ADDCOLUMNS(CROSSJOIN(TableL,TableF),"combine",[L]&[F]),"c",[combine]))

 

Capture2.PNG

At last , create frenquent column for the new table:

Frequency(Count) = CALCULATE(COUNT('Table'[Text in code]),FILTER('Table',LEFT('Table'[Text in code]) = LEFT(COMBINE[Combination])&&LEFT('Table'[Text in code],7) = LEFT(COMBINE[Combination],7))) 

 

Capture3.PNG

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

View solution in original post

3 REPLIES 3
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try to create three table for P L F:

TableP = SELECTCOLUMNS(CALCULATETABLE(VALUES('Table'[Text in code]),FILTER('Table',LEFT('Table'[Text in code])="P")),"P",[Text in code])

TableL = SELECTCOLUMNS(CALCULATETABLE(VALUES('Table'[Text in code]),FILTER('Table',LEFT('Table'[Text in code])="L")),"L",[Text in code])

TableF = SELECTCOLUMNS(CALCULATETABLE(VALUES('Table'[Text in code]),FILTER('Table',LEFT('Table'[Text in code])="F")),"F",[Text in code])

 

Then create the combination table:

 

COMBINE = UNION(TableP,TableL,TableF,SELECTCOLUMNS(ADDCOLUMNS(CROSSJOIN(TableP,TableL),"combine",[P]&[L]),"c",[combine]),SELECTCOLUMNS(ADDCOLUMNS(CROSSJOIN(TableP,TableF),"combine",[P]&[F]),"c",[combine]),SELECTCOLUMNS(ADDCOLUMNS(CROSSJOIN(TableL,TableF),"combine",[L]&[F]),"c",[combine]),SELECTCOLUMNS(ADDCOLUMNS(CROSSJOIN(TableP,TableL,TableF),"combine",[P]&[L]&[F]),"c",[combine]),SELECTCOLUMNS(ADDCOLUMNS(CROSSJOIN(TableL,TableF),"combine",[L]&[F]),"c",[combine]))

 

Capture2.PNG

At last , create frenquent column for the new table:

Frequency(Count) = CALCULATE(COUNT('Table'[Text in code]),FILTER('Table',LEFT('Table'[Text in code]) = LEFT(COMBINE[Combination])&&LEFT('Table'[Text in code],7) = LEFT(COMBINE[Combination],7))) 

 

Capture3.PNG

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

Greg_Deckler
Community Champion
Community Champion

@Anonymous - So, what are we frequency counting in the 2nd table? Are we doing this by the date (Fecha) or by the Ubicacion column? Seems similar to what I came up with here:

Distinct Column Combinations - Microsoft Power BI Community

 

 



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

Hi Greg, thanks for your help! Hope you're ok.


We are counting the amount of times that the codes in the third row (Starting with P, L or F) appear in the first table. Then we count the amount of combinations (order doesn't matter) that we can do with all the P, L or F codes that we generate by combining them into one string line. The date and location are merely informational to relate the table with another ones.

 

Imagine we've got this situation:

AnibalPb3_2-1620986767167.png

So, our text detector, gets 6 pieces of atribute code (Starting with P, L or F):

AnibalPb3_1-1620986716058.png

So our frequency table in the combinatorial analysis (second table) would be like this:

AnibalPb3_0-1620986666848.png

I think I'm not missing any combination between them, correct me if I'm wrong. In every case that P000001 is involved, the count must be at least 2, because of the number of combinations that you can do with that atribute.

 

I don't care if the job is done in Power Query or using DAX, but as a measure it won't work because I need that table as a registered table, not as a Matrix. I hope you can help me 🙂

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.