Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
psk180590
Creator III
Creator III

Sum leads to false values.

Hello All,

I have a straight excel table with some Market, Product, Year, Month and Sales values.

MarketProductYearMonthSales
1AA2017Jan100
1BB2017Feb200
2FR2017Jan300

Script:

Temp:

Load

Market,

Product,

Year,

Month,

Sales

From Sample.xls;

Join(Temp)

Load

Market,

Year,

Month,

Sum(Sales) as MarketSales

Resident Temp

Group by Market, Year, Month;

After the load my final table which i'm saving in an qvd looks this.

MarketProductYearMonthSalesTotalMarket
1AA2017Jan100300
1BB2017Feb200300
2FR2017Jan300300


Up to this everything looks fine.

In the next step i'm looking to display this results in my application via an Table(All the results) and also a graph(Only Market Share of each Product).


And here i have couple of Expressions - Sum(Sales) as ProductSales and Sum(TotalMarket) as MarketSales.

ProductSales works fine but the MarketSales gives me wrong values(Ex: Here for Market 1 it is giving me 600).


Can you please help me with writing a formula where the original values of TotalMarket(300 for Market 1) will be displayed instead of 600.



TIA!!

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

You dont need to create the total in script.

You can do that in chart only.

Have a look at the app attached.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

9 Replies
tresesco
MVP
MVP

Try grouping the sales only on Market like:

Temp:

Load

Market,

Product,

Year,

Month,

Sales

From Sample.xls;

Join(Temp)

Load

          Market,

          Sum(Sales) as MarketSales

Resident Temp

Group by Market;

psk180590
Creator III
Creator III
Author

Hello Tresesco,

Thanks for the quick suggestion. Even this didn't help me.

Capture.JPG

Here the first and second columns should be same and in the third column first Row it should display 100%

tresesco
MVP
MVP

Could you post a sample qvw?

psk180590
Creator III
Creator III
Author

Attached Data and App.

Thanks!

PrashantSangle

Try,

Sum(Total<Market> Sales)

Regards,

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 🙂
psk180590
Creator III
Creator III
Author

Hi Prashant,

You mean in the Join?

If so then i should also do a GroupBy Market?

Thanks!!

PrashantSangle

Where do you want to achieve it in Front end or in back end??

Solution which i have provided work in front end

in back end Tresesco solution will work for you in his solution add group by field on which level you want to group it.

Regards,

Prashant

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 🙂
tresesco
MVP
MVP

Try using second expression with DISTINCT keyword like :

sum(DISTINCT {<Year={$(vYear)}>} SalesMarket)

Capture.PNG

However, this could have been done easily without this complexity.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

You dont need to create the total in script.

You can do that in chart only.

Have a look at the app attached.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!