6 Replies Latest reply: Oct 20, 2016 6:45 AM by Sunny Talwar

# Total in all rows

Hi all,

I have this table in Qlik Sense:

And I am using the following expression for last column:

sum(Aggr(Sum({\$<Product=,Flag={'Sales'}, Source={'MySales'}>}Value),Year_Month))

I get the total (I want the total of the first column - 859 709 705.56) on the total aggr column, but I want this value to be shown in all rows. Because basically I will need to divide the first column values by this last value.

Does anybody know how to do this?

Cheers,

Inês

• ###### Re: Total in all rows

Try this:

Sum(TOTAL <Year_Month> {\$<Product=,Flag={'Sales'}, Source={'MySales'}>}Value)

• ###### Re: Total in all rows

Unfortunately that does not work because if I do that, it will somehow not consider the Year_Month... and it will give me the totals for ALL months.

• ###### Re: Total in all rows

I am not sure why it wouldn't consider Year_Month if we specifically gave the field name Year_Month in the total qualifier? Are you sure you added this?

Sum(TOTAL <Year_Month> {\$<Product=,Flag={'Sales'}, Source={'MySales'}>}Value)

• ###### Re: Total in all rows

I guess the alternative might be to do something like this:

Aggr(NODISTINCT Sum({\$<Product=,Flag={'Sales'}, Source={'MySales'}>}Value), Year_Month)

• ###### Re: Total in all rows

I did, I also don't understand why the first option is not working...

But it worked with the NODISTINCT could you please explain me how exactly it works?

Once again, Thank you so much!!

Inês

• ###### Re: Total in all rows

When you used only one dimension from your chart within your Aggr() function, there is a grain mis-match. And when this happens, the value is assigned to just one of the rows instead of getting populated all rows. By adding NODISTINCT you can ask Aggr() to populate those values on all rows. Read some more about this here:

Pitfalls of the Aggr function