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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
marcel_olmo
Partner Ambassador
Partner Ambassador

Amount distributed per Dimension

Hi guys,

I have a table with sales per area and vendor like this :

Area Vendor Amount
Area1Vendor12444 €
Vendor23000 €
Vendor35236 €
Area2Vendor41629 €
Vendor54828 €
Total 17138 €

And I'd like to create another field in the script which distributes the total amount between the total number of Vendors. In this case would be 17.138 € / 5 vendors = 3.428 €.

The desired result would be :

Area.png

I've attached a dummy example of what I'm trying.

Regards, Marcel.

1 Solution

Accepted Solutions
sunny_talwar

May be this:

VendorAmounts:

LOAD Area,

    Vendor,

    Amount

FROM

VendorAmounts.qvd

(qvd);

Join(VendorAmounts)

LOAD Avg(Temp) as Temp1;

LOAD Area,

  Vendor,

  Sum(Amount) as Temp

Resident VendorAmounts

Group By Area, Vendor;

Join(VendorAmounts)

LOAD Area,

  Vendor,

  Count(Vendor) as Temp2

Resident VendorAmounts

Group By Area, Vendor;

Final:

LOAD Area,

    Vendor,

    Amount,

    Temp1/Temp2 as [Distributed Amount]

Resident VendorAmounts;

DROP Table VendorAmounts;


Capture.PNG

View solution in original post

6 Replies
sunny_talwar

Check this out:

VendorAmounts:

LOAD Area,

    Vendor,

    Amount

FROM

VendorAmounts.qvd

(qvd);

Join(VendorAmounts)

LOAD Avg(Temp) as [Distributed Amount];

LOAD Area,

  Vendor,

  Sum(Amount) as Temp

Resident VendorAmounts

Group By Area, Vendor;


Capture.PNG

sunny_talwar

or you can use this in the front end without needing to do anything in the script:

Avg(TOTAL Aggr(sum(Amount), Area, Vendor))

Capture.PNG

marcel_olmo
Partner Ambassador
Partner Ambassador
Author

Thanks for the try sunindia

I suppose that in layout would be easier than in script, but in this case it has to be like this.

The point is to get the same total but distributed equally per vendors, in your case, the only() function does not work for me because I need it inside a sum() function.

Regards, Marcel.

sunny_talwar

May be this:

VendorAmounts:

LOAD Area,

    Vendor,

    Amount

FROM

VendorAmounts.qvd

(qvd);

Join(VendorAmounts)

LOAD Avg(Temp) as Temp1;

LOAD Area,

  Vendor,

  Sum(Amount) as Temp

Resident VendorAmounts

Group By Area, Vendor;

Join(VendorAmounts)

LOAD Area,

  Vendor,

  Count(Vendor) as Temp2

Resident VendorAmounts

Group By Area, Vendor;

Final:

LOAD Area,

    Vendor,

    Amount,

    Temp1/Temp2 as [Distributed Amount]

Resident VendorAmounts;

DROP Table VendorAmounts;


Capture.PNG

marcel_olmo
Partner Ambassador
Partner Ambassador
Author

Great sunindia! That was it! Regards, Marcel.

sunny_talwar

Awesome