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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
JCERVANTES
Frequent Visitor

Sorting a calculated measure in descending order. All values stored as text in a measure.

I'm struggling with sorting a concatenated text value stored in a measure. I have a table of data used for voting statistics. One requirement that I'm dealing with is taking vote totals and displaying them in a concatenated string. The results are as shown...

JCERVANTES_0-1739380080385.png

I've acheived this view using the following DAX:

VAR DistinctValues = DISTINCT('Supply Chain Committee Votes Details'[VoteChoice])
VAR ValueCounts =
    ADDCOLUMNS(
        DistinctValues,
        "Count",
        CALCULATE(COUNTROWS('Supply Chain Committee Votes Details'), FILTER('Supply Chain Committee Votes Details', 'Supply Chain Committee Votes Details'[VoteChoice]= EARLIER('Supply Chain Committee Votes Details'[VoteChoice])))
    )
RETURN
    CONCATENATEX(
        ValueCounts,
        FORMAT([Count], "(#)") & " " & 'Supply Chain Committee Votes Details'[VoteChoice] & " ", " ", " "
    )
 
The part of struggling with now, is sorting the result in descending order from left to right. I had "high" hopes that it would sort natively (that's just me asking for too much). I've tried just about every function, even trying to create a new column except the results I'm looking for are not panning out.
JCERVANTES_1-1739380537189.png

 Anyone have any ideas? Can't seem to wrap my head around it. Unfortunately I cannot supply any data samples

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Try using the order by argment in CONCATENATEX.

 

I think it works like this:

VAR ValueCounts =
    SUMMARIZE (
        'Supply Chain Committee Votes Details',
        'Supply Chain Committee Votes Details'[VoteChoice],
        "@Count", COUNTROWS ( 'Supply Chain Committee Votes Details' )
    )
RETURN
    CONCATENATEX (
        ValueCounts,
        FORMAT ( [@Count], "(#) " ) & 'Supply Chain Committee Votes Details'[VoteChoice],
        " ",
        [@Count], DESC
    )

View solution in original post

2 REPLIES 2
JCERVANTES
Frequent Visitor

Thank you! That worked. I see where I was going wrong.

JCERVANTES_0-1739459923780.png

 

AlexisOlson
Super User
Super User

Try using the order by argment in CONCATENATEX.

 

I think it works like this:

VAR ValueCounts =
    SUMMARIZE (
        'Supply Chain Committee Votes Details',
        'Supply Chain Committee Votes Details'[VoteChoice],
        "@Count", COUNTROWS ( 'Supply Chain Committee Votes Details' )
    )
RETURN
    CONCATENATEX (
        ValueCounts,
        FORMAT ( [@Count], "(#) " ) & 'Supply Chain Committee Votes Details'[VoteChoice],
        " ",
        [@Count], DESC
    )

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.