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: 
Abhi_WP
Contributor III
Contributor III

Max function partition by a dimension value

PayNo DayDtRow NoMax(Row No)
111824|2008202014
111824|2008202024
111824|2008202034
111824|2008202044
2587|1705202012
2587|1705202122

 

I have first two columns in my script and I want to populate  max of row no (3rd column) for each unique combination of PayNo DayDt. Any help will be apprecaited.

Labels (2)
1 Solution

Accepted Solutions
tresesco
MVP
MVP

You are using this expression in script? It was not meant for that. In script you can't use TOTAL; if you use aggregation function like max(), you have to use it in combination with Group By clause. 

And that's why it is very important to explain your requirement more in details; giving business context...and that could help you getting faster solution; minimize helping people here having to come back for unnecessary follow up queries for clarifications.  

View solution in original post

6 Replies
lironbaram
Partner - Master III
Partner - Master III

hi 

you can use 

max(total <PayNo DayDt>Row No)

Abhi_WP
Contributor III
Contributor III
Author

Hi, 

Is it missing one bracket ?

I am getting below error

 

Error in expression:
')' expected
tresesco
MVP
MVP

It is not missing ')', however, it has other issues. If your field name contains spaces it has to be surrounded by double quotes or square brackets or any valid other quotes. Although, I guess resolving this alone would not give you the right result. You need to create a new field in the script, like:

Load Subfield([PayNo DayDt], 1) as PayNo

And then use this PayNo in the expression/dimension for desired result.

Abhi_WP
Contributor III
Contributor III
Author

I have square brackets around the field. This is my current expression

[Temp2 Raw Timesheet Dim]:
Load *,
Max(TOTAL <[PayNo DayDt]> DayRunningCount) as LastRowValue,
Resident [Temp1 Raw Timesheet Dim];

As suggested by you, I will create this new field and will see the result.

Thanks

 

tresesco
MVP
MVP

You are using this expression in script? It was not meant for that. In script you can't use TOTAL; if you use aggregation function like max(), you have to use it in combination with Group By clause. 

And that's why it is very important to explain your requirement more in details; giving business context...and that could help you getting faster solution; minimize helping people here having to come back for unnecessary follow up queries for clarifications.  

Abhi_WP
Contributor III
Contributor III
Author

Thanks for your suggestion. 

I created a temp table and used group by function to take the max of it. And then, joined it back to the main table.