Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Split data for specific cells only

Hello,

I have the following data:

TitleDwnIDTypeDownloads
Title11same20
Title21same0
Title32same40
Title42same0
Title53dif60
Title64dif80

and I want to split the Downloads for titles which have the same DwnID:

TitleDwnIDTypeDownloads
Title11same10
Title21same10
Title32same20
Title42same20
Title53dif60
Title64dif80

If I use Sum({<Type={'same'}>} Downloads/2) I get the right values for Titles which already have a Downloads value but for the rest the value stays '0'.

Any suggestions?

Kind Regards,

Ivelin

Labels (1)
1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

See attached qvw


talk is cheap, supply exceeds demand

View solution in original post

10 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You can calculate it with avg(total <DwID> Downloads). See attached example.


talk is cheap, supply exceeds demand
Not applicable
Author

Hey thanks Gysbert but it doesn't really work in my case.

Downloads/2 was also only one of the cases I have, for others the calculation should be Downloads*30%, for example.

sujeetsingh
Master III
Master III

Why dont you give sample

Not applicable
Author

Title1 and Title2 have 20 and 0 in downloads according to the first table and in reality they both have 10 downloads each. That's because these 2 titles share the same DwnID. On the other side, Titles 5 and Title6 have different DwnIDs and thus the values of 60 and 80 are the correct.

TitleDwnIDTypeDownloads
Title11same=20*50%
Title21same=20*50%
Title32same=40*50%
Title42same=40*50%
Title53dif60
Title64dif80
Not applicable
Author

Here it is

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

See attached qvw


talk is cheap, supply exceeds demand
Not applicable
Author

That's what I'm looking for, thanks!

Not applicable
Author

Hi Gysbert,

I encountered an issue with this solution - selecting a Title returns its original value instead. Is there another way around it and/or is it possible/better to do it in the Script?

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You could try this:

sum({1<DwnID=p(DwnID)>} total <DwnID> Downloads )/count({1<DwnID=p(DwnID)>} total <DwnID> DISTINCT Title)

If you select a title you get the list of titles with the same DwID as the selected title.

But it's probably better done in the script. Maybe adding this will do the trick:

join load sum(Downloads)/count(distinct Title) as SplitDwnl, DwnID

resident Table1 group by DwnID;


talk is cheap, supply exceeds demand