-
Re: Issue about date dimensions
Sunny Talwar Apr 3, 2018 7:58 AM (in response to Sofia Vaz)In QlikView you can add Year as your second dimension, but not sure if Qlik Sense allow it or not... have you tried adding year as the second dimension?
-
Re: Issue about date dimensions
Sofia Vaz Apr 3, 2018 9:13 AM (in response to Sunny Talwar )yes i've tried. If I add them as a second dimension I'm forced to choose one of them, but i'm not allowed to see weeks of 2017 and weeks of 2018 separately
-
-
Re: Issue about date dimensions
Petter Skjolden Apr 3, 2018 8:37 AM (in response to Sofia Vaz)It is not possible in a bar chart to have two dimensions and multiple measures in Qlik Sense.
The way to achieve it is to combine the year and week into one dimension and make some logic to not include the year into label of the dimension more than every 13th week or so - each quarter approximately. Then you can get a bar chart like this:
-
Temp.qvf 240.0 K
-
Re: Issue about date dimensions
Sofia Vaz Apr 3, 2018 9:15 AM (in response to Petter Skjolden )Thank you Petter! I can only achieve this by creating a new field on the script, or it can be done on the app?
-
Re: Issue about date dimensions
Petter Skjolden Apr 3, 2018 9:30 AM (in response to Sofia Vaz)It's your choice.... actually I did make a new field in the script of the attached application. But in the bar chart I made a calculated dimension - not using the field created in the script.... So you can have a look at both approaches.
-
Re: Issue about date dimensions
Sofia Vaz Apr 3, 2018 9:47 AM (in response to Petter Skjolden )Thank you Peter! I'm not able to open your file... can you please share here the expression of that calculated dimension, please?
-
Re: Issue about date dimensions
Petter Skjolden Apr 3, 2018 10:19 AM (in response to Sofia Vaz)Sure....
The dimension looks like this:
=Dual( If(FMod(Week,13)=1,Year&'-')&Week&Repeat(' ',$(=Max(Year))-Year) , Year*100+Week)
The Dual() function is used to have a display value that is treated as a text and a numeric value that is use for calculations. The text part which is the first parameter is before the very last comma in the expression. I have added a lot of spaces for clarity in the expression above.
By using the FMod(Week,13=1 I can add some text every 13th Week. The added text is the Year and it gets prepended along with a dash/hyphen before the Week number. Then comes the week number. Lastly "invisible" spaces are added as replacements for the years so Qlik have for instance week 4 in 2017 different from week 4 in 2018 even though it doesn't look like it since the spaces are "invisble".
If the trick is hard to understand you could simply use this expression:
=Dual(Year&'-'&Week, Year*100+Week)
Then every Week will have a year in front of it - the bar chart gets less readable but it works the same.
-
Re: Issue about date dimensions
Sofia Vaz Apr 3, 2018 11:46 AM (in response to Petter Skjolden )Thank you very much, Petter! That works perfectly!
-
Re: Issue about date dimensions
Petter Skjolden Apr 3, 2018 11:47 AM (in response to Sofia Vaz)You're welcome happy to help.
-
-
-
-
-
-