Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
May 18th 10AM ET, Live Chat, bring your QlikView questions. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Expression with Altered State

Hello,

I need to create a table that compares two time periods. The end user can define "current period" and "prior period". The user should have the option of comparing the following:

* Current [Month] to Previous [Month]

* Current [Quarter] to Previous [Quarter]

* Current [Year] to Previous [Year]

I have established that the best way to handle this is by using altered states so I have created a "Group 1" which will be Current Period and "Group 2" which will be Prior Period.

My table should ultimately look like this, where the user selected Q4 2014 as Current Period, as an example, and Q3 2014 for Prior Period.

Metric

Prior Period

Q3 2014

Current Period

Q4 2014

Difference

Total Dollars$100,000$130,00030.0%
Total People347

301

-13.3%

I will need to have separate filters for each group. Both filters will include the same information but the user can select different dates to compare.

My filter:

Multi Box that includes a three drop downs options; one for year, one for QuarterYear, and one for MonthYear.

So the user should only be able to select one of the three options within one group. A Year or a QuarterYear, or a MonthYear (i.e. 2014 or Dec 2014 or Q4 2014)

Is this possible to do? Can someone help me out with the expressions that I need to use? One expression will be in the column header to make the date reference dynamic and the other would be in the cells in each column to actually add data just from the selected time period.

I'm tackling this one step at a time so this is the next step to my first question on how to achieve the prior / current comparison...answer was to user alternate states, which I'm now trying to do:)

Thank you so much!

1 Solution

Accepted Solutions
reshmakala
Creator III
Creator III

Hello,

am not sure if this is what you are looking. Please look at the attached file. Let me know if you have a different question.

View solution in original post

12 Replies
reshmakala
Creator III
Creator III

Hello,

am not sure if this is what you are looking. Please look at the attached file. Let me know if you have a different question.

View solution in original post

Not applicable
Author

Your example is exactly what I was looking for. Thank you!

I am, however, having trouble implementing it with my data. Do you know what might be wrong with this expression?

count(DISTINCT({Group 2}[LocationID]))

I'm getting an error with the opening squiggly bracket...not the closing.

reshmakala
Creator III
Creator III

You are welcome. Sorry for the delay. There is a small correction in your expression.

Please try

count ( {Group2} DISTINCT (LocationID) )

Let me know if that doesn't work.

Not applicable
Author

It looks like the syntax is correct however it's returning null and the answer should be 171. Any thoughts on why it would return null?

This is what I entered as the expression...

count({[Group 2]}DISTINCT[LocationID])

reshmakala
Creator III
Creator III

Can you attach a file with sample data?

reshmakala
Creator III
Creator III

See this

Not applicable
Author

I am not seeing a file if you attached one with your "see this" post...BUT I was just playing around with it and somehow I tweaked something and it works!! Not sure what the magic change was but what matters is it is returning the correct amount.

Thank you so much, Reshma. Your example is what helped me through it.

Not applicable
Author

One other question, Reshma...in your example you have one row of data. How would you set it up if you needed to have several rows of data where you show the group1 and group2 results in separate columns?

reshmakala
Creator III
Creator III

In my example, I just did a summation of data values, when you use pivot table and have multiple rows, you would be able to find the same with you current selections.