Forum Discussion
how to sort Date (MonthYear column)?
Hi Jolyon,
In case you want to sort by Year and Month of date, you could add Calcuated column for YearMonthInt as:
YearMonthInt = Dates[Date].[Year]*100 + Dates[Date].[MonthNo]
Then choose MonthYear column and choose sort by YearMonthInt column.
If this works for you please accept it as solution and also like to give KUDOS.
Best regards
Tri Nguyen
- Jolyon9 years ago
Helper III
hi tringuyenminh92
could you please also tell, how you concatenated MonthYear?
Question to this formula: YearMonthInt = Dates[Date].[Year]*100 + Dates[Date].[MonthNo] : is Dates the name of table? "Year" and "MonthNo" are your columns or DAX functions?
because in my case PowerBI underlines this formula as red: YearMonthInt = Client[Datum].[Jahr]*100 + Client[Datum].[Mon]thank you kindly!
- tringuyenminh929 years ago
Memorable Member
When we cast Date column to Date type, PBI will suport us to access its Month (month name) and Month value (MonthNo)
My MonthYear= Dates[Date].[Month] & "-" & Dates[Date].[Year]
I think your expression of YearMonthInt is correct, just choose sort by column.
- Jolyon9 years ago
Helper III
tringuyenminh92
hm, it is a bit strange, because I get error message from Power BI, that says : the variation column Month and Year couldn't be found in the table:Table1 is name of my table; Date is name of my Date column; I have Date in format dd.mm.yyyy.
I tried both German and English in the formula for the Month and Year, but it doesn't work.
And the same problem with YearMonthInt = Dates[Date].[Year]*100 + Dates[Date].[MonthNo] --> in my report I get error message.Is DATES in your report the name of your table?
thanks for the help!
- Anonymous8 years agoNot applicable
Hi tringuyenminh92 I am having this kind of data in reports and also wnat to sort as same Jolyon sorting for his reports
means if multiple years data we have first it will sort by year in that case . But how to prepared calculate colum for above scenario as per above data. help me here i am new to DAX querys. also not having date column in my all tables so please suggest me how to achive that sorting on multiple year data
- Anonymous6 years agoNot applicable
This worked for me! Thanks!
- Daviejoe6 years ago
Memorable Member
Worked for me so thank you tringuyenminh92
- SA_NYC6 years ago
Advocate I
Wow, I'd been looking what felt like everywhere for an answer to this problem, somehow no other site or video suggested that trick of multiplying the year by 100, that's what made it work for me. More than three years after you wrote the post, too. Thanks!
- yatsunau3 years agoNew Member
wow this is one of the question from PL-300 certifications!
where do you learn this?