Forum Discussion
DAX code to select 3 minimum values across matrix row, then return a concatenation of said values
Hello, thank you all for taking the time to reply to my post. I am looking for help in writing a DAX code which iterates through a matrix row and selects the top three minimum values, then returns a concatenation of the three minimum values in text for. For example, the table below returns the three minimum values for each row of the matrix:
I've tried setting up a DAX code using a combination of variables, temp tables, MINX, and concatentation, but the concatentation will only pick up the first piece of text and will leave out the remaining piece of text. Any help would be greatly appreciated!!
Create a new measure as
Minimum Three = var tmpTable = { ( "Cost of living", SELECTEDVALUE('Table'[Cost of living])), ( "Housing", SELECTEDVALUE('Table'[Housing])) ... etc } return CONCATENATEX( TOPN( 3, tmpTable, [Value2], ASC), [Value1], ", ")
8 Replies
- johnt75
Super User
You could try adding a calculated column as
Minimum Three = var tmpTable = { ( "Cost of living", 'Table'[Cost of living]), ( "Housing", 'Table'[Housing]) ... etc } return CONCATENATEX( TOPN( 3, tmpTable, [Value2], ASC), [Value1], ", ")- iluvcoding_91
Helper I
Hi, thank you for your reply. Is there a way to set this up w/o using calculated columns and using a measure only? I have a live connection to the datasource so unfortunately I can't created calculated columns...
- johnt75
Super User
I think it should work if you wrap each column reference inside SELECTEDVALUE
- iluvcoding_91
Helper I
How would I set that up?
- johnt75
Super User
Create a new measure as
Minimum Three = var tmpTable = { ( "Cost of living", SELECTEDVALUE('Table'[Cost of living])), ( "Housing", SELECTEDVALUE('Table'[Housing])) ... etc } return CONCATENATEX( TOPN( 3, tmpTable, [Value2], ASC), [Value1], ", ")