Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Changing the labels name in bar chart

HI all,

I want to change the labels name in the bar chart. so i have used the below query for dimensions.

IF(match(question_id, '1'), Replace(question_id, '1', 'Q1'),

IF(match(question_id, '2'), Replace(question_id, '2', 'Q2'),

IF(match(question_id, '3'), Replace(question_id, '3', 'Q3'),

IF(match(question_id, '4'), Replace(question_id, '4', 'Q4'),

IF(match(question_id, '5'), Replace(question_id, '5', 'Q5'),

IF(match(question_id, '6'), Replace(question_id, '6', 'Q6'),

IF(match(question_id, '7'), Replace(question_id, '7', 'Q7'),

IF(match(question_id, '8'), Replace(question_id, '8', 'Q8'),

IF(match(question_id, '9'), Replace(question_id, '9', 'Q9'),

IF(match(question_id, '10'), Replace(question_id, '10', 'Q10'),question_id))))))))))

To restrict the data to 10 bars i have used Limitation to "Fixed number".

But it is displaying some other question id's from the table.

Please see the image i have attached.finaltest.png

Thanks,

Pramod

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi Pramod,

If you are always selecting the range of questions as 10 like 10-20, 20-30, 151-60, then use below solution.

LOAD

*,

'Q' & No AS Qno,

Q' & If(fmod(No , 10) = 0, 10, fmod(No , 10)) AS QNoMod

FROM DataSource;

Now use QNoMod as Dimension.

It is not a good practice to use Calculated dimension in the charts, it affects the performance issues and lot of other issues. 

Also it is a good practice to share some sample file for sample data in community to get the answers quickly, people won't have time to prepare sample data, sample file and solution to give. If you provide sample data it saves lot of time and for better understanding.

Go through this link it helps you in getting the successful answers quickly.

Qlik Community Tip: Posting Successful Discussion Threads

Regards,

jagan.

View solution in original post

11 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi Pramod,

In script itself you can bring one new column with Qn number like below

LOAD

*,

'Q' & No AS Qno

FROM DataSource;

Now you can use this expression if you want to show Q1 to Q10.

=Sum({<Qno={'Q1', 'Q2','Q3','Q4','Q5','Q6','Q7','Q8','Q9','Q10'}>} MeasureName)

Regards,

Jagan.

Not applicable
Author

Hi jagan,

The scenario is i have question_id's around 200 if i select question_id's from 151 to 160 at that time i don't want to display as Q151 to Q160. I need that also in Q1 to Q10 so i am using replace.

You can see in the below image.count1.png

Thanks,

Pramod

Anonymous
Not applicable
Author

Hi Pramod,

I'm not 100% sure about your final output, but changing slightly Jagan's suggestion, please try the following:

In the script, create an additional field:

LOAD

     *,

     dual('Q' & No,No) AS Qno

FROM DataSource;

Then in the chart use this expression:

=Sum({<Qno={">=1<=10"}>} MeasureName)


If you want to "skip" the selection against Qno, then your expression should look like this:

=Sum({<Qno=, Qno={">=1=<10"}>} MeasureName)


Now if you select Qno betweeen 151 and 160 the other chart will still display number between 1 and 10.


I hope it will help.


Best regards,

Janusz

jagan
Luminary Alumni
Luminary Alumni

Hi Pramod,

If you are always selecting the range of questions as 10 like 10-20, 20-30, 151-60, then use below solution.

LOAD

*,

'Q' & No AS Qno,

Q' & If(fmod(No , 10) = 0, 10, fmod(No , 10)) AS QNoMod

FROM DataSource;

Now use QNoMod as Dimension.

It is not a good practice to use Calculated dimension in the charts, it affects the performance issues and lot of other issues. 

Also it is a good practice to share some sample file for sample data in community to get the answers quickly, people won't have time to prepare sample data, sample file and solution to give. If you provide sample data it saves lot of time and for better understanding.

Go through this link it helps you in getting the successful answers quickly.

Qlik Community Tip: Posting Successful Discussion Threads

Regards,

jagan.

Not applicable
Author

Hi jagan,

I have used the above load script but what expression should be used in dimension or measures to get the data.

please explain. I am attaching the sample data.

Thanks,

Pramod

jagan
Luminary Alumni
Luminary Alumni

You can use your current expression itself, no change in that just change the dimension in the chart to QNoMod.


Regards,

Jagan.

Not applicable
Author

I used QNoMod in dimensions, but it is displaying only 5 values not 10 values.

Regards,

Pramod

jagan
Luminary Alumni
Luminary Alumni

I think there is issue with the data, check the data whether you have all the numbers from 1 to 10 for your selection.

Regards,

Jagan.

Not applicable
Author

Yes, i have data for what i want.

For example: if i want display question_id from 151 to 160 it is printing with labels151 to 160. and data is also correct.

now just i want to change that labels from 151 - 160 to Q1 to Q10.

if i used the script given by you it's printing only Q1 to Q5.

Thanks,

Pramod