# New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save \$400. Learn More
Contributor II

## Sum Max

I have the following expression and I want to only see the Max New_Reporting_Period but for some reason I can't get my head round it

=count(distinct If(DaysToTS_Acc<21,Risk_No))

I'm sure it's simple!

1 Solution

Accepted Solutions
MVP

## Re: Sum Max

Actually these might also work:

Max

Count(DISTINCT {<DaysToTS_Acc = {'<21'}, New_Reporting_Period = {"\$(=Max(New_Reporting_Period))"}>} Risk_No)

2nd Max

Count(DISTINCT {<DaysToTS_Acc = {'<21'}, New_Reporting_Period = {"\$(=Max(New_Reporting_Period, 2))"}>} Risk_No)

10 Replies
MVP

## Re: Sum Max

May be this

FirstSortedValue(Aggr(Count(DISTINCT {<DaysToTS_Acc = {'<21'}>} Risk_No), New_Reporting_Period), -New_Reporting_Period)

MVP

## Re: Sum Max

This should show the count for the Max New_Reporting_Period

MVP

## Re: Sum Max

What is the format of New_Reporting_Period  field?

Contributor II

## Re: Sum Max

Awesome, thanks Sunny, and to do the previous month?

MVP

## Re: Sum Max

This

FirstSortedValue(Aggr(Count(DISTINCT {<DaysToTS_Acc = {'<21'}>} Risk_No), New_Reporting_Period), -New_Reporting_Period, 2)

MVP

## Re: Sum Max

Actually these might also work:

Max

Count(DISTINCT {<DaysToTS_Acc = {'<21'}, New_Reporting_Period = {"\$(=Max(New_Reporting_Period))"}>} Risk_No)

2nd Max

Count(DISTINCT {<DaysToTS_Acc = {'<21'}, New_Reporting_Period = {"\$(=Max(New_Reporting_Period, 2))"}>} Risk_No)

Contributor II

## Re: Sum Max

Yes, these worked perfectly. Thank you

Contributor II

## Re: Sum Max

Last question on this, can this be adapted to be a rolling 3 month? so included the Max 3 months?

MVP

## Re: Sum Max

May be this

Count(DISTINCT {<DaysToTS_Acc = {'<21'}, New_Reporting_Period = {"\$(='>=' & Max(New_Reporting_Period, 3) & '<=' & Max(New_Reporting_Period))"}>} Risk_No)