Forum Discussion
mespiritu
Helper I
2 years agoHelp sort 12 rolling months in order
Can someone help assist with how to sort the following by earliest month year Jul23 to latest June24 - I'm trying to sort by Attritubue using Jul23 as the first month to June24 as the last...
mespiritu
Helper I
2 years agoHi thank you for explaning above - what sample code can I use if I want my attributes from Jul23 to June24? and If I'd like to change up my attributes every month since I have to update dashboard monthly.
collinsg
Solution Sage
2 years agoGood day mespiritu ,
One thing I hadn't noticed before was that your month names were a mix of 3 and 4 letter abbreviations. Your screenshot shows your data contains a column "Attribute" - so long as this column contains Jul23 to June24 then you need one line of code, which is modified from the previous code to cater for the 3/4 letter abbreviation mix.
= Table.AddColumn(#"Previous Step", "Sort Date", each Date.FromText(Text.Start([Attribute],3) & Text.End([Attribute],2),[Format="MMMyy"]), type date)
Select the last step in your query, press the fx on the formula bar, then paste in the code.
Hope this helps