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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to capture every distinct transition in a table with concatenatex and earlier?

Dear Community,

 

Let's say that I have this table:

 

 

ID Index Status
A 1 X
A 2 X
A 3 Y
A 4 Y
A 5 Y
A 6 Z
A 7 Z
B 8 X
B 9 Y
B 10 Y
B 11 Z
B 12 Z
B 13 Z
C 14 A
C 15 B
C 16 A
C 17 A
C 18 P
C 19 P
C 20 F

 

 

 

I want to capture the different transitions of the statusses by ID.

So this should be the result:

 

 

ID Index Status Transitions
A 1 X X-Y-Z
A 2 X X-Y-Z
A 3 Y X-Y-Z
A 4 Y X-Y-Z
A 5 Y X-Y-Z
A 6 Z X-Y-Z
A 7 Z X-Y-Z
B 8 X X-Y-Z
B 9 Y X-Y-Z
B 10 Y X-Y-Z
B 11 Z X-Y-Z
B 12 Z X-Y-Z
B 13 Z X-Y-Z
C 14 A A-B-A-P-F
C 15 B A-B-A-P-F
C 16 A A-B-A-P-F
C 17 A A-B-A-P-F
C 18 P A-B-A-P-F
C 19 P A-B-A-P-F
C 20 F A-B-A-P-F

 

 

 

This is the DAX script I am currently using but it doesn't give me the right (distinct) result:

 

 

= CONCATENATEX(FILTER(Table;Table[ID]=EARLIER(Table[ID]));Table[Status];"-";Table[Index])

 

 

 

I am currently getting the following result:

 

 

ID Index Status Transitions
A 1 X XX-YYY-ZZ
A 2 X XX-YYY-ZZ
A 3 Y XX-YYY-ZZ
A 4 Y XX-YYY-ZZ
A 5 Y XX-YYY-ZZ
A 6 Z XX-YYY-ZZ
A 7 Z XX-YYY-ZZ
B 8 X X-YY-ZZZ
B 9 Y X-YY-ZZZ
B 10 Y X-YY-ZZZ
B 11 Z X-YY-ZZZ
B 12 Z X-YY-ZZZ
B 13 Z X-YY-ZZZ
C 14 A A-B-AA-PP-F
C 15 B A-B-AA-PP-F
C 16 A A-B-AA-PP-F
C 17 A A-B-AA-PP-F
C 18 P A-B-AA-PP-F
C 19 P A-B-AA-PP-F
C 20 F A-B-AA-PP-F

 

 

 

Any help is appreciated!

1 ACCEPTED SOLUTION

@Anonymous try this measure

 

Unique Status = 
CONCATENATEX( 
CALCULATETABLE( 
VALUES ( 'Table'[Status] ), 
ALLEXCEPT('Table', 'Table'[ID ] ) 
), 
'Table'[Status], 
"-" 
)

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

Throw a DISTINCT in there:

 

= CONCATENATEX(DISTINCT(FILTER(Table;Table[ID]=EARLIER(Table[ID])));Table[Status];"-";Table[Index])


@ 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!:
The Definitive Guide to Power Query (M)

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

Thanks @Greg_Deckler for your response. The formula didn't work for me.

I got the following message:

Failed to save modifications to the server. Error returned: 'A circular dependency was detected: Table[Transition].
'. 

============================
Call Stack:
============================

at Microsoft.AnalysisServices.Tabular.Model.SaveChanges(SaveOptions saveOptions)
at Microsoft.AnalysisServices.Tabular.Model.SaveChanges(SaveFlags saveFlags)
at Microsoft.AnalysisServices.BackEnd.DataModelingSandboxTabular.UpdateDatabase()
at Microsoft.AnalysisServices.BackEnd.SandboxTransactionTabular.CommitUpdates()
at Microsoft.AnalysisServices.BackEnd.DataModelingSandbox.CommitUpdates()
at Microsoft.AnalysisServices.BackEnd.DataModelingView.Update()
at Microsoft.AnalysisServices.BackEnd.DataModelingView.UpdateAddedColumns(List`1 addedColumns, List`1 oldExpressions, IList`1 colIndices)
at Microsoft.AnalysisServices.BackEnd.DataModelingView.ChangeFormulas(IList`1 colIndices, IList`1 names, IList`1 expressions, Boolean suspendImpact)
at Microsoft.AnalysisServices.BackEnd.DataModelingView.ChangeFormulas(IList`1 colIndices, IList`1 names, IList`1 expressions)
at Microsoft.AnalysisServices.Common.SandboxEditor.ChangeFormula(TableWidgetPanel currentTable, IList`1 colIndices, IList`1 names, IList`1 expressions, Boolean doFormulaBarCommit, IList`1 displayIndices)

============================

 

 Do you have any suggestions?

@Anonymous try this measure

 

Unique Status = 
CONCATENATEX( 
CALCULATETABLE( 
VALUES ( 'Table'[Status] ), 
ALLEXCEPT('Table', 'Table'[ID ] ) 
), 
'Table'[Status], 
"-" 
)

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k I don't get the results I want to have. I have added a variant (ID 'C') which result isn't correct.

 

This script only concatenate the unique statusses:

Test = CONCATENATEX(
CALCULATETABLE(
VALUES ( Blad1[Status] );
ALLEXCEPT(Blad1; Blad1[ID] )
);
Blad1[Status];
"-"
)
 
Could you help me out with this? (Or should I post a new question?)

@Anonymous would recommend to create a new post and tag me in it. Also share sample data.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k  Thanks for your help!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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