Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
SAMJB
Contributor
Contributor

How to calculate maximum month for each quarter and for year from the available data set

SAMJB_0-1652425981770.png

How to calculate maximum month for each quarter and for year from the available data set


I have Fiscal year, Month, Quarter, Headcount columns, I want to display max month of headcount in every  quarter and  year in table chart.

Can someone help me on this.

 

Labels (1)
14 Replies
MayilVahanan

HI

Try like below

For Quarter: Sum({<Gender = {'M'}>}Sales) / Sum(Sales))

For Max month of Quarter: Sum(Aggr(If(Month = Max(Total<Quarter, Year>Month), Sum({<Gender = {'M'}>}Sales) / Sum(Sales)), Quarter, Month, Year))

If not works, pls attach the sample file with expected result

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
SAMJB
Contributor
Contributor
Author

Hi Mayil Vahanan,

Thanks for your response.

Below expression i have modified.


Sum(Aggr(If([Fiscal Month] = Max(Total<FiscalQuarter, [Fiscal Year]>[Fiscal Month]),
Count({<Gender = {'M'}>}[PS No]) / Count (distinct [PS No])), FiscalQuarter, [Fiscal Month], [Fiscal Year]))

total percentage is above 100

SAMJB_0-1652777893869.png

 

 

 

SAMJB
Contributor
Contributor
Author

In Pivot table i want to display headcount and gender wise data only max month of every Quarter for all year

below one is full data in table for selected year

SAMJB_1-1652778581620.png

Below sample data in pivot table

SAMJB_2-1652778891991.png

below expression I'm using for gender

Count({<Gender={'M'}>}distinct [PS No])/Count(distinct [PS No])

 

 

MayilVahanan

Hi

In that case, u need to use Avg

Avg(Aggr(If([Fiscal Month] = Max(Total<FiscalQuarter, [Fiscal Year]>[Fiscal Month]),
Count({<Gender = {'M'}>}[PS No]) / Count (distinct [PS No])), FiscalQuarter, [Fiscal Month], [Fiscal Year]))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
SAMJB
Contributor
Contributor
Author

Hi MayilVahanan,

Thanks for the Expression, It's working fine.

Avg(Aggr(If([Fiscal Month] = Max(Total<FiscalQuarter, [Fiscal Year]>[Fiscal Month]),
Count({<Gender = {'M'}>}[PS No]) / Count (distinct [PS No])), FiscalQuarter, [Fiscal Month], [Fiscal Year]))

I have one more doubt.

With same expression i wont to show max month headcount of the year means Mar month.

SAMJB_1-1653386519100.png