# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

New Contributor II

## AVG if

Hi all,

My table is like that and

I want to calculate the average of Tx de marge but I Don't want to take the value if date fin contrat <31/08/2018 and if Matricule facturation = INTERNE

1 Solution

Accepted Solutions
Esteemed Contributor

## Re: AVG if

Hi,

try this:

Avg({<[date fin contrat]={">31/08/2018"},[Matricule facturation]-={'INTERNE'}>}Marge)

13 Replies
Esteemed Contributor

## Re: AVG if

Hi,

try this:

Avg({<[date fin contrat]={">31/08/2018"},[Matricule facturation]-={'INTERNE'}>}Marge)

New Contributor II

## Re: AVG if

thanks a lot

Esteemed Contributor

## Re: AVG if

you're welcome

good luck

New Contributor II

## Re: AVG if

after changement of date, it doesn't work

I think that it's because the formula exclude the empty value in date fin de contrat.

New Contributor II

## Re: AVG if

after changement of date, it doesn't work

I think that it's because the formula exclude the value of marge when in date fin de contrat the value is empty

New Contributor II

## Re: AVG if

I try this formula without success

Avg({<[Début de contrat]={"<=31/08/2018"},[Date fin de contrat]-={"<31/08/2018"},[Matricule facturation]-={'INTERNE'}>}Marge)

Esteemed Contributor

## Re: AVG if

Yes because it is static inside the expression.

you can make it dynamic but how you will select a different date ?

New Contributor II

## Re: AVG if

how can make it dynamic ?

I create a variable = 31/08/2018

and when I want to change the date, i Change the value of the variable

Esteemed Contributor

## Re: AVG if

you need to put your variable inside the expression, like this:

Avg({<[date fin contrat]={">\$(your_variable_name)"},[Matricule facturation]-={'INTERNE'}>}Marge)