Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
andrefpc
Partner - Creator II
Partner - Creator II

Year Month sort

Hello community,

In a chart I have a calculated date dimension to get the year and the month, like this:

year & '-' & month

but I'm unable to sort this dates, any ideas?

thanks in advance!

1 Solution

Accepted Solutions
alexandros17
Partner - Champion III
Partner - Champion III

use year * 100 + month, in this way you will have always numbers of 6 digits ex. 201401, 201402 ...

Sorting in this way is natural

Hope it helps

View solution in original post

5 Replies
alexandros17
Partner - Champion III
Partner - Champion III

use year * 100 + month, in this way you will have always numbers of 6 digits ex. 201401, 201402 ...

Sorting in this way is natural

Hope it helps

andrefpc
Partner - Creator II
Partner - Creator II
Author

Great! Worked like a charm, thanks Alessandro.

sivarajs
Specialist II
Specialist II

Try this in your sort expression

left(yearmonth,4)&Right(yearmonth,2)

nhlakadee84
Contributor
Contributor

Thank you!

This was quite helpful for me.

martinpohl
Partner - Master
Partner - Master

Hi,

month is a dual field. With a dual field you can show the string and sort by number.

If you are using monthname(Date) you will get Apr. 2019 for today, depending on your monthname settings and can sort by the numeric values.

If you want to show 2019 - 04 or 04 - 2019 you can load

dual(num(month(Date),'00' & '- ' & year (Date),year(Date)&num(month(Date),'00')) as Monthname

Show your field monthname and sort it by number if not by default.

Regards