Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
ValentinDes
Contributor
Contributor

Date sorting problem in a 2-lines chart

Hello Community! 

First of all excuse my bad english. 

I had to do a graph that compares 2 different years, and more specifically n days at the near-end-period. Basically it looks the n days before 31/05/2024 and n days before 31/05/2023, i show it in the same graph in 2 different lines with the same scale. For exemple for the 1st of September i want to see in my graph 01 Sept in the dimension and 1000€ in blue for 2024 and 2000€ in red for 2023.

MyDate is at format DD/MM/YYYY and i am doing this : 

Dimension : 

 

Day(MyDate) & ' ' & Month(MyDate)

 

Measure 1 : 

 

Sum({< MyDate = {"=MyDate>= Num(Date('$(vDateMax)','DD/MMM')) - $(vNearPeriodEnd)"} >} Amount)

 

 Measure 2 : 

 

Sum({<MyDate={"=MyDate<= Num(Date('31/05/23','DD MMM')) and MyDate>=Num(Date('31/05/23','DD MMM'))- $(vNearPeriodEnd)"}>}Amount)

 

 

And it works very well,

BUT i can't sort dates in the chronological order (without taking care of the year) and i tried lot of things : 

Sorting by expression with "MyDate" or "Day(MyDate) & ' ' & Month(MyDate)" or Numerically or Alphabetically and i tried to create in the script "Date(NewDate,'DD MMM') as NewDate" and still doesnt work 

Hope some of you have an idea. 

Thanks !! 

Val

Labels (5)
4 Replies
Kushal_Chawda

@ValentinDes  What did you get if you remove all the sorting option for that dimension?

ValentinDes
Contributor
Contributor
Author

@Kushal_Chawda still random sorting 

brunobertels
Master
Master

Hi 

Try to use dual() for sorting

 

dual(

Day(MyDate) & ' ' & Month(MyDate) , 

Day(MyDate) & ' ' & num(Month(MyDate)) 

madelonjansen
Partner Ambassador
Partner Ambassador

Or, create a new field that is an actual data (and therefore a dual) that you use as the dimension.
Using the Date() function, you can format dates any way you want 🙂 

Date([datefield], 'D MMMM') as [PrettyDateField]