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
Anonymous
Not applicable

sorting dates that have been concatenated via new quick measure tool

hi,

 

i created a measure to list dates using the new quick measure tool & the resultant dax is as flws:

YYYY+MMM.List =
VAR __DISTINCT_VALUES_COUNT = DISTINCTCOUNT('Calendar'[YYYY+MMM])
VAR __MAX_VALUES_TO_SHOW = 3
RETURN
    IF(
        __DISTINCT_VALUES_COUNT > __MAX_VALUES_TO_SHOW,
        CONCATENATE(
            CONCATENATEX(
                TOPN(
                    __MAX_VALUES_TO_SHOW,
                    VALUES('Calendar'[YYYY+MMM]),
                    'Calendar'[YYYY+MMM],
                    ASC
                ),
                'Calendar'[YYYY+MMM],
                ", ",
                'Calendar'[YYYY+MMM],
                ASC
            ),
            ", etc."
        ),
        CONCATENATEX(
            VALUES('Calendar'[YYYY+MMM]),
            'Calendar'[YYYY+MMM],
            ", ",
            'Calendar'[YYYY+MMM],
            ASC
        )
    )
 
its purpose is to include the dates list in my visual title/captioning. however, the dates r listed alphabatically (eg. 2018-oct followed by 2018-sep) instead of chronologically (i.e. 2018-sep followed by 2018-oct). kindly  advise on how to resolve this in the dax above (that's generated via the new quick measure tool).
 
tks. -nik
6 REPLIES 6
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You may create [YearMonth] column firstly, then select on the 'Calendar'[YYYY+MMM], go to Column tools ->Sort by column, choose [YearMonth].

 

YearMonth = VALUE(FORMAT('Calendar'[Date],"yyyymm"))

sort by.PNG

Best Regards,

Amy 

 

Community Support Team _ Amy

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

Anonymous
Not applicable

tks @v-xicai,

 

the solution seems to work for YYYY-MM column (createdd by YYYY+MM = FORMAT('Calendar'[Date], "yyyy-mm"). 


however, if i select the YYYY+MMM column (created by YYYY+MMM = 'Calendar'[YYYY]&"-"&'Calendar'[MMM]), i stil down get the column sorted chronologically.

 

i believe i'm still missing something.

 

appreciate any help.

tks, -nik

Hi @Anonymous ,

 

The data type of the two formulas below as you said is text . So I recommend you try the my formula " YearMonth = VALUE(FORMAT('Calendar'[Date],"yyyymm")) ", which is using VALUE function to convert text type to number type . Then follow the steps above.

 

This is Text type:

 

YYYY+MM = FORMAT('Calendar'[Date], "yyyy-mm" )

 

YYYY+MMM = 'Calendar'[YYYY]&"-"&'Calendar'[MMM])

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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

@Anonymous did you use sort by as recommended by @v-xicai. Here is a post I wrote on calendar table and that use sort by method. I hope this helps.

 


I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



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.

amitchandak
Super User
Super User

@Anonymous ,Can you share sample data and sample output in table format?

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

hi @amitchandak,

as the file contains sensitive data from my client, i'm unable to share the pbix. additionally, its datasource is a dataset in pbi service.

many tks still.

krgds, -nik

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.

Top Kudoed Authors