Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
klaus_feldam
Creator II
Creator II

Use of Max() in Dimension AND Expression

Running into a bit of a challenge with something that, logically, should be fairly simple.

DateJobIDStatus
07/31/201312In Progress
07/24/201312Closed
07/20/201312Cancelled
08/12/201497In Progress
07/31/201497In Progress

From this example table, I only want to report on the last entry by JobID, where Status = 'In Progress' - 07/31/2013 for JobID 12 and 08/12/2014 for JobID 97.

I don't want to include any previous JobIDs, regardless of their status.

I would appreciate your assistance with this issue.

I have tried using the Max function in both Dimension and Expression formulas, but don't get the desired result.

My desired result would be:

YearMonthStatus# of Job IDs
2013JulyIn Progress1
2014AugustIn Progress1
1 Solution

Accepted Solutions
Anonymous
Not applicable

Try using calculated dimension as Date:

aggr(max(if(Status='In Progress', Date)),JobID)

You maybe need JobID as another dimension.  I didn't test.

View solution in original post

5 Replies
Anonymous
Not applicable

Try using calculated dimension as Date:

aggr(max(if(Status='In Progress', Date)),JobID)

You maybe need JobID as another dimension.  I didn't test.

Not applicable

Status. Date and JobId as dimension and try this in your expression:

count(aggr(if(max(TOTAL <JobID> Date)=Date, count({<Status = {'In Progress'}>} JobID)), JobID, Date))

simenkg
Specialist
Specialist

The use of calculated dimensions can work if the amount of data is very small. 

I would rather do this in the script.

Do something like this:

Table:
Load Date, JobID, Status from Source.qvd ....;

left join(Table)

load Date,JobID,

if(peek(JobID)=JobID,null(),1) as %ValidJobIDFlag

resident Table

where Status = 'In Progress'

order by Date desc;

Then in your front end you use Year, Month and Status as dimensions and the expression:

Count({<%ValidJobIDFlag={1}>}distinct JobID)

Hope this helps
SKG

klaus_feldam
Creator II
Creator II
Author

Thank you Padmaja Gade, Simen Kind Gulbrandsen and Michael Solomovich for your very quick responses.

All very helpful and spot on!

klaus_feldam
Creator II
Creator II
Author

Padjmaja,

Using your logic above, how would you create a sum for a new column called [Number of Systems]?

I would only want the Number of Systems counted for the Max(Date) by JobID.

Appreciate your insight and experience.

Klaus