So this is a little tricky, but think I have a solution for you (I won't go into why you are using dates in this way!....Tableau has some amazing date handling features, as long as fields are real dates, so worth taking a look...it will make your life easier!)
However, onto the problem....
So the first thing I did was to recreate your [Month Num] (I've called mine [Month INT])...which is likely to be more efficient than a 12 step IF statement.
I'll *try* and explain what it's doing! (starting in-to-out on the nesting)
The DATEPARSE bit, is creating a date, for the first of the month of 2015;
The DATEADD bit is altering the date, so that Month 1 is April
THE DATEPART bit is then taking just the Month INTEGER out from this (so the year, I've used 2015, is irrelevant)
Next bit, is to use this to create a REAL date from your YEAR and MONTH (using Month INT)
Once we have this I can then use the MIN of this field to sort your String
Hope that does the trick, and makes sense...let me know if not.
Sorting.twbx 36.3 KB
An easier way to do this would be to avoid the concatenation. On concatenation, tableau is going to consider the field to be a string and sort it alphabetically.
You can filter the data based on your date to have only two years of data and use MONTH(date) as the dimension. You can have the measures aggregated as per your need after that.
Hope this helps!
Thank you so much. The solution worked..