Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Dimensions for Week over Week comparison in a Bar Chart

Hello,

I am am creating a bar chat showing a Week over Week comparison. My Expression 1 was created to only show data for the current week. The second expression was created to only show data for the prior week.

However, I have my x-axis as CC_Week and it does not show the week number. I have also tried to change out the dimension for Week(CC_Date), but that does not seem to work as well. Please see my expressions below:

Current Week:

=Sum({1<CC_Date = {">=$(=Date(WeekStart(Max(CC_Date)), 'M/D/YYYY'))

                                      <=$(=Date(WeekEnd(Max(CC_Date)), 'M/D/YYYY'))"}>} [Answered])

Prior Week:

=Sum({1<CC_Date = {">=$(=Date(WeekStart(Max(CC_Date),-1), 'M/D/YYYY'))

                                      <=$(=Date(WeekEnd(Max(CC_Date),-1), 'M/D/YYYY'))"}>} [Answered])

I would think that my final result would show two dates (or week numbers) on the x-axis.

1 Solution

Accepted Solutions
Not applicable

Re: Dimensions for Week over Week comparison in a Bar Chart

Of course I can!

Your dimension would be:

Valuelist("Current Week", "Prior Week")

Your expression would be:

pick(Rowno(),

    Sum({1<CC_Date = {">=$(=Date(WeekStart(Max(CC_Date)), 'M/D/YYYY'))

                                      <=$(=Date(WeekEnd(Max(CC_Date)), 'M/D/YYYY'))"}>} [Answered]),


    Sum({1<CC_Date = {">=$(=Date(WeekStart(Max(CC_Date),-1), 'M/D/YYYY'))

                                      <=$(=Date(WeekEnd(Max(CC_Date),-1), 'M/D/YYYY'))"}>} [Answered])

)

The structure is:

Pick(Rowno(),

     first_expression,

     second_expression

)

if you have more than 2 expression, just write them, don't forget the "," at the end

7 Replies

Re: Dimensions for Week over Week comparison in a Bar Chart

Can you show the image of what you have right now?

Not applicable

Re: Dimensions for Week over Week comparison in a Bar Chart

6-20-2016 4-51-42 PM.png

Re: Dimensions for Week over Week comparison in a Bar Chart

So you want to show the week number on the axis? That is what is missing?

Not applicable

Re: Dimensions for Week over Week comparison in a Bar Chart

You can use "value list" as a calculated dimension, and a function "pick".

See the img and qvw

Edit: You can also use variables or expressions on value list

Not applicable

Re: Dimensions for Week over Week comparison in a Bar Chart

yes that is correct

Not applicable

Re: Dimensions for Week over Week comparison in a Bar Chart

My current expressions are:

Current Week:

=Sum({1<CC_Date = {">=$(=Date(WeekStart(Max(CC_Date)), 'M/D/YYYY'))

                                      <=$(=Date(WeekEnd(Max(CC_Date)), 'M/D/YYYY'))"}>} [Answered])

Prior Week:

=Sum({1<CC_Date = {">=$(=Date(WeekStart(Max(CC_Date),-1), 'M/D/YYYY'))

                                      <=$(=Date(WeekEnd(Max(CC_Date),-1), 'M/D/YYYY'))"}>} [Answered])

Can you assist me in how I would add the Pick(RowNo(), to the above?

Thanks!

Not applicable

Re: Dimensions for Week over Week comparison in a Bar Chart

Of course I can!

Your dimension would be:

Valuelist("Current Week", "Prior Week")

Your expression would be:

pick(Rowno(),

    Sum({1<CC_Date = {">=$(=Date(WeekStart(Max(CC_Date)), 'M/D/YYYY'))

                                      <=$(=Date(WeekEnd(Max(CC_Date)), 'M/D/YYYY'))"}>} [Answered]),


    Sum({1<CC_Date = {">=$(=Date(WeekStart(Max(CC_Date),-1), 'M/D/YYYY'))

                                      <=$(=Date(WeekEnd(Max(CC_Date),-1), 'M/D/YYYY'))"}>} [Answered])

)

The structure is:

Pick(Rowno(),

     first_expression,

     second_expression

)

if you have more than 2 expression, just write them, don't forget the "," at the end

Community Browser