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
Taoufiq_Zarra

@SAMJB  do you mean Max(total <Quarter> Value) ?

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
vinieme12
Champion III
Champion III

flag the latest month within each quarter in your load script

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
SAMJB
Contributor
Contributor
Author

SAMJB_0-1652430911315.png


Yes! I want to show Quarter wise max month.

Please tell me the Set Analysis exp for this or what condition need to write for this in script

MayilVahanan

HI 

In Front end,  if you don't have access to edit script means, try like below,

Aggr(If(Month = Max(Total<Quarter, Year>Month), Sum(Sales)), Quarter, Month, Year)

Else, In Script, 

MasterCalendar:
LOAD
Year(CalDate) as Year,
WeekDay(CalDate) as WeekDay,
'Q' & Ceil(Month(CalDate)/3) as Quarter,
QuarterName(CalDate) as QuarterName,
Month(CalDate) as Month,
If(Month(CalDate) = Month(QuarterEnd(CalDate)), 1, 0) as MaxMonthFlag,
Date(MonthStart(CalDate), 'MM-YYYY') as MonthYear,
1000*Rand() as Sales;
LOAD
Date($(vMinDate) + IterNo()-1) as CalDate
AutoGenerate 1
While $(vMinDate) + IterNo()-1 <= $(vMaxDate);

Front End: Sum({<MaxMonthFlag={1}>}Sales)

Based on ur requirement, Change based on Fiscal calendar.

MayilVahanan_1-1652437130559.png

 

 

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

Hello Mayilvahanan,

Thanks/Nandri for your response.

But for fiscal year 2022-23 we have loaded April month data Q1 that data will not flow if i use above logic.
So i need to display that data also, based on that please help with logic.

for Eg. fiscal year 2021-22 we have Q1 and all three month Apr, May and Jun. in table default jun month data should be display  and based on selection Apr month data also display

 

SAMJB_0-1652439649171.png

 

SAMJB
Contributor
Contributor
Author

Below expression is working, But i/m not getting the total. please find the attached screenshot.

Aggr(If(Month = Max(Total<Quarter, Year>Month), Sum(Sales)), Quarter, Month, Year)

 

SAMJB_0-1652452774984.png

 

MayilVahanan

HI 

Try like below

Sum(Aggr(If(Month = Max(Total<Quarter, Year>Month), Sum(Sales)), Quarter, Month, 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 it's working fine.

Sum(Aggr(If(Month = Max(Total<Quarter, Year>Month), Sum(Sales)), Quarter, Month, Year))

One more doubt please. I want to add Gender = ('M') nd Gender =('F') separate column in percentage. Please help me with this.

 

SAMJB_0-1652678395241.png

Regards
SamJB

SAMJB
Contributor
Contributor
Author

Hi MayilVahanan,

Awaiting for your response.