5 Replies Latest reply: May 22, 2015 3:47 PM by Jonas Melo

# Divide the sum of 2 number fields

Hello,

I need to divide the sum of 2 number fields.  I've tried this:

==Sum({\$<[Date] = {'>=\$(vMaxDateMinus6)'}, RecordType = {'Table Name'}>}[Weighted_Avg_Spread])

/

Sum({\$<[Date] = {'>=\$(vMaxDateMinus6)'}, RecordType = {'Table Name'}>}[Amount])

I need this to come up as a percentage.  What I'm really trying to get is the Weighted Average.

• ###### Re: Divide the sum of 2 number fields

=Num(Sum({\$<[Date] = {'>=\$(vMaxDateMinus6)'}, RecordType = {'Table Name'}>}[Weighted_Avg_Spread])

/

Sum({\$<[Date] = {'>=\$(vMaxDateMinus6)'}, RecordType = {'Table Name'}>}[Amount]),'0%')

hope this helps

regards

Marco

• ###### Re: Divide the sum of 2 number fields

Hi guys, thanks for the response.  I know that I'm not expressing my question correctly, so, please allow me to express it in a language I do know.  If I were to try to do what I want to do in Qlikview in SQL, it would look like this:

From [Table Name]

Where [Table Name].[MaxDate] - 6 = [Table Name].[BusinessDate] (This is vMaxDateMinus6)

I basically need an Expression that does that in a Text Box on a Sheet.

• ###### Re: Divide the sum of 2 number fields

Translating into QV would be Marco´s answer

• ###### Re: Divide the sum of 2 number fields

Hi, Dennis Chen.

I understand that the variable vMaxDateMinus6 is formed by using Makedate() function . For example: Max(MakeDate(Year(Now())-1,month(Now()-210),15)).

However, a expression goinna be:

Num(Sum({\$<[Date] = {">=\$(vMaxDateMinus6)"}, RecordType = {'Table Name'}>}[Weighted_Avg_Spread]) / Sum({\$<[Date] = {">=\$(vMaxDateMinus6)"}, RecordType = {'Table Name'}>}[Amount]),'##.##%').

Attention, the quotation marks (") in modifier of the date.

Hope this help.