Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for
Did you mean:
Contributor III

## Percentage Calculation

Hello Community ,

i'm facing a little problem with my new application , on the chart i wanna calculate the percentege of my Dimension by year like this : ( As you can see the %Sales on red is calculated by deviding 585 788 by 771 397 )

The EXPRESSION I WROTE IS :  Count(DISTINCT Sales )/Count(TOTAL DISTINCT <Ex> sales) but it doesn't give me the result i want

 Ex. Pack Gar Total sales % sales 2020 P1 585 788 76% 2020 P2 142 815 19% 2020 P3 57 890 8% 2020 P4 164 0% 2020 Total 771 397 100% 2019 P1 598 953 78% 2019 P2 149 498 19% 2019 P3 41 163 5% 2019 P4 24 0% 2019 Total 772 540 100%

i tried so many expression by the way, but none of them worked for me .

I really hope u helping me .

Thank you once again

1 Solution

Accepted Solutions
Contributor III
Author

yes i agree with both of youu ! but the situation obliged me to use count instead of sum..
cuz i wouldn't  put some secret info so i used and example by sales .

So THE SOLUTION was pretty similar :

Count(DISTINCT IMMATRICULATION)
/
Count( DISTINCT TOTAL <Ex_gar_auto> IMMATRICULATION)

Thank you @PrashantSangle & @MindaugasBacius for ur kind time.. and sorry for my late response .

4 Replies
Partner - Contributor III

Can you please help in understanding whether total for each year will be same as P1+P2+P3+P4 or not.

In data I can see it differs.

Partner - Specialist III

Do field Sales represent Sales ID or number?

I guess try using Sum instead of Count.

Yes @MindaugasBacius is correct. try below code

Sum(Sales) / Sum(Total <Ex> Sales)

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Contributor III
Author

yes i agree with both of youu ! but the situation obliged me to use count instead of sum..
cuz i wouldn't  put some secret info so i used and example by sales .

So THE SOLUTION was pretty similar :

Count(DISTINCT IMMATRICULATION)
/
Count( DISTINCT TOTAL <Ex_gar_auto> IMMATRICULATION)

Thank you @PrashantSangle & @MindaugasBacius for ur kind time.. and sorry for my late response .

Tags