Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
ahammadshafi
Contributor

Dynamic columns based on calculation

Dear Experts:

Here is the requirement from my client.

They want to update a report monthly where the columns of a table will be generated and named dynamically based on a calculation.

For example, in the sales table they will have the following columns

Sample Data.PNG

The report will show the following

Requirement.PNG

In the report

  1. The first column will show the products which has some changes in sales against "Sales Today".

  2. Only those months will be shown where there is changes in sales

               Here, for Product "A" there is change (1 unit) against 3rd previous month.

                         for Product "B" there are changes in sales against 1st and 3rd month.

                         for Product "C" there are changes in sales against 1st and 3rd month.

               But there is no changes in sales against 2nd month - as a result the report didn't show anything like "Change against 2nd                month"

Seeking your opinions to achieve this requirement.

Sample data is attached.

Shafi

Tags (2)
1 Solution

Accepted Solutions
varshavig12
Valued Contributor

Re: Dynamic columns based on calculation

12 Replies
singhpooja
Contributor III

Re: Dynamic columns based on calculation

Hi Ahammad,

Apply following expression:

Dimension :- Product

Expression1:Change against 1st month:- [Sales last month]-[Sales Today]

Expression2:Change against 3rd month:- [Sales Today]-[Sales 3 months back]

From above you will get following reselt

ProductChange against 1st monthChange against 3rd month
A01
B23
C-15


Thanks,

singhpooja
Contributor III

Re: Dynamic columns based on calculation

Hey I am correcting my above expressions:

Dimension :- Product

Expression1:Change against 1st month:- [Sales Today]-[Sales last month]

Expression2:Change against 3rd month:- [Sales Today]-[Sales 3 months back]

From above you will get following result

ProductChange against 1st monthChange against 3rd month
A01
B-23
C15

Thanks,

Re: Dynamic columns based on calculation

Till Report, i am happy. After that, i am not sure i understand your rek. Would you share the epected result to show

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
varshavig12
Valued Contributor

Re: Dynamic columns based on calculation

conditional Hide/Show

varshavig12
Valued Contributor

Re: Dynamic columns based on calculation

Chart Straight table,

Dim - Product, today Sales

Expression - 1.     [Sales last month]-[Sales Today]

                    2.     [Sales 2 months back]-[Sales Today]

                    3.     [Sales 3 months back]-[Sales Today]

PRESENTATION -

     Conditional show/hide --- for exp 2:      if(sum(total([Sales 2 months back]-[Sales Today]))=0,0,1)

and so on for others

varshavig12
Valued Contributor

Re: Dynamic columns based on calculation

Oh! It is current - last month

So just make the change in the formula:

Like:

[Sales Today]-[Sales last month]

[Sales Today]-[Sales 2 months back]

[Sales Today]-[Sales 3 months back]

PRESENTATION -

     Conditional show/hide --- for exp 2:      if(sum(total([Sales Today]-[Sales 2 months back]))=0,0,1)

and so on for others

I hope this helps!

ahammadshafi
Contributor

Re: Dynamic columns based on calculation

Hi All:

Many thanks for your replies.

Sorry that I missed one point - it is not fixed that client will want to show the difference only for 3 months. The number of months could vary; like it can be 4 months or 5 months or 2 months. It will depend on the input data they will provide.

Hi Anil:

Please let me rephrase the requirement in words.

In input data the the client will share today's sales and sales of few previous months (the number of months can vary - like it can have 1 month or 2 months or 3 months.... or 9 months).

In the report we have to show the difference in sales with previous months. No columns will be shown if there is no difference with a month.

In the given example there are sales of previous 3 months, but tomorrow they can share input data with only 2 previous months. So, tomorrow the number of columns in the table should decrease.

Please let me know if that helps.

Shafi

ahammadshafi
Contributor

Re: Dynamic columns based on calculation

Hi Varsha:

Many thanks.

Sorry that I missed one requirement. The number of expression will vary based on the number of months given in input data. In next refresh the client may give 4 previous months data or 5.

Shafi

varshavig12
Valued Contributor

Re: Dynamic columns based on calculation

ahh!

Okay, no problem.

Can you please tell me how you get this data from your client ?

Just like in excel i.e this month, last month , last 2 month

or in proper months like 112016, 102016 etc.