Summing on the latest record with MDX
I'm trying use MDX to sum up the most recent [Employee Compensation].[Employee Scheduled Hours] member for each [Employee].[Employee] but in the context of the the current query. Employee Compensation is a type II dimension, and an Employee can change scheduled
hours from week to week (but we just want to see the most recent). How can I roll this up properly in a calculated member? Sample data is like:
EmployeeKey
EmployeeCompensationKey
DateKey
100
40
20140101
100
20
20140107
200
40
20140101
200
30
20140107
In this case, if I roll up 2014 January, I would expect to see a sum of (20 + 30) =
60 for the Employee Scheduled Hours. Please note, the EmployeeCompensationKey in the sample table is actually a surrogate key to the Employee Compensation dimension with the attribute of Employee Scheduled Hours. I've just put the member values
here for simplification.
I'm using the following MDX query, but this only works for certain scenarios. How would I set up this? I have a feeling the set I'm returning from TAIL function is probably the issue.
SUM(
EXISTING(DESCENDANTS([Employee].[Employee].[All],,AFTER)),
STRTOVALUE(
TAIL(
NONEMPTY(
[Employee Compensation].[Scheduled Hours].[Scheduled Hours],
{[Measures].[Headcount]}),
1).Item(0).NAME
Dimensionality for the LASTNONEMPTY function is over the date/time dimension, so if an employee got several checks in the same day, it would sum up the measure for that employee for that day.
I'd rather not have to create a new fact measure, but I suppose I'll look into using a windowing function or another alternative to populate the scheduled hours on only one of those one-to-many records at the same time.
One last idea is that, I know I can pull the tuple of last scheduled hour per each employees as so:
DESCENDANTS([Employee].[Employee].[All],,AFTER)
TAIL(TOPCOUNT(DESCENDANTS([Employee Compensation].[Scheduled Hours].[All],,AFTER),1,[Measures].[Headcount]),1).item(0)
But I don't know how to extract from this tuple, just the set of employee scheduled hours portion...
Similar Messages
-
Query to find the latest record with respect to the current status
Dear gurus
I have the following data in a table
Customernum
bkcode
reqtdate
Prevstat
currstat
The data will be like this
CustomerNum bkcode reqdate prevstat currstat
5900 1 03-Aug-12 0 1
5900 1 06-Aug-12 1 0
5900 5 22-Jun-12 0 1
If a customer has an issue to solved, a record is added with bkcode , register date and currstat will be 1
If the issue is resolved for the bookingcode,a new record is added, the currentstatus will become 0. and prev stat will show 1. Row no 1 and 2 reflects this case
If this table is queried for finding the unresolved issues. the output should be only the Last row of the above example. since issue with bookingcode 1 has been resolved
I have trying hard to get this thing confused what to use Lead or Max
Kindly guide meHi,
one way here:
WITH mytable(CustomerNum, bkcode, reqdate, prevstat, currstat)
AS
SELECT 5900, 1, TO_DATE('03-Aug-12', 'DD-Mon-YY'), 0, 1 FROM DUAL UNION ALL
SELECT 5900, 1, TO_DATE('06-Aug-12', 'DD-Mon-YY'), 1, 0 FROM DUAL UNION ALL
SELECT 5900, 5, TO_DATE('22-Jun-12', 'DD-Mon-YY'), 0, 1 FROM DUAL
SELECT CustomerNum, bkcode, reqdate, prevstat, currstat
FROM (SELECT a.*
, ROW_NUMBER() OVER (PARTITION BY CustomerNum, bkcode
ORDER BY reqdate DESC) AS rn
FROM mytable a
WHERE rn=1
AND currstat=1;
CUSTOMERNUM BKCODE REQDATE PREVSTAT CURRSTAT
5900 5 22-JUN-12 0 1Regards.
Al
Edited by: Alberto Faenza on Dec 18, 2012 5:23 PM
Changed again!! Previous logic was wrong -
Select the one record with the latest record
I have the following table called tblSales:
SKU TransDate Color
=== ====== ====
123 1/1/2015 Red
123 1/2/2015 Red
123 1/5/2015 Red
123 1/1/2015 White
123 1/2/2015 White
123 1/3/2015 White
123 1/1/2015 Blue
123 1/2/2015 Blue
123 1/5/2015 Blue
I need to create a query along the lines "SELECT the latest record FROM tblSales WHERE Color = 'White''
In this example, the record dated 1/3/2015 would be the result. I know that MAX(TransDate) is used here, but not sure how.
Thanks.
KenKarl,
I had already tried that. It returns all 3 records having SKU = 123 and Color = White.
Worst case scenario is I can always search for White 123s using a query with TransDate DESC and then get the first record. I was just hoping for something a bit more elegant.
Thanks for your help though.
Ken -
Hi ,
How to find out the latest Record in per_all_people_f and per_all_assignments_f
Requirement : Need to find out the latest record in per_all_people_f and per_all_assignments_f to update the attribute column with pre defined value . Its not possible to track only with person_id / assignment_id and effective end date
SELECT pp_id
FROM (SELECT app.person_id pp_id,
asf.*
FROM apps.per_all_people_f app,
apps.per_all_assignments_f asf
WHERE --app.person_id=123568 and
asf.person_id = app.person_id AND
app.effective_end_date = to_date('31-dec-4712') AND
asf.effective_end_date = to_date('31-dec-4712')
GROUP BY app.person_id)
HAVING COUNT(pp_id) > 1
GROUP BY pp_id
This query also returns more than 1 value for person_id .
It would be great if you put comment on this .. Thanks in advance ,
AryaI am getting more records with asf.primary_flag='Y' . If you give ur mail id , i will send the sample data
ASSIGNMENT_ID EFFECTIVE_START_DATE EFFECTIVE_END_DATE BUSINESS_GROUP_ID RECRUITER_ID GRADE_ID POSITION_ID JOB_ID ASSIGNMENT_STATUS_TYPE_ID PAYROLL_ID LOCATION_ID PERSON_REFERRED_BY_ID SUPERVISOR_ID SPECIAL_CEILING_STEP_ID PERSON_ID RECRUITMENT_ACTIVITY_ID SOURCE_ORGANIZATION_ID ORGANIZATION_ID PEOPLE_GROUP_ID SOFT_CODING_KEYFLEX_ID VACANCY_ID PAY_BASIS_ID ASSIGNMENT_SEQUENCE ASSIGNMENT_TYPE PRIMARY_FLAG APPLICATION_ID ASSIGNMENT_NUMBER CHANGE_REASON COMMENT_ID DATE_PROBATION_END DEFAULT_CODE_COMB_ID EMPLOYMENT_CATEGORY FREQUENCY INTERNAL_ADDRESS_LINE MANAGER_FLAG NORMAL_HOURS PERF_REVIEW_PERIOD PERF_REVIEW_PERIOD_FREQUENCY PERIOD_OF_SERVICE_ID PROBATION_PERIOD PROBATION_UNIT SAL_REVIEW_PERIOD SAL_REVIEW_PERIOD_FREQUENCY SET_OF_BOOKS_ID SOURCE_TYPE TIME_NORMAL_FINISH TIME_NORMAL_START BARGAINING_UNIT_CODE LABOUR_UNION_MEMBER_FLAG HOURLY_SALARIED_CODE REQUEST_ID PROGRAM_APPLICATION_ID PROGRAM_ID PROGRAM_UPDATE_DATE ASS_ATTRIBUTE_CATEGORY ASS_ATTRIBUTE1 ASS_ATTRIBUTE2 ASS_ATTRIBUTE3 ASS_ATTRIBUTE4 ASS_ATTRIBUTE5 ASS_ATTRIBUTE6 ASS_ATTRIBUTE7 ASS_ATTRIBUTE8 ASS_ATTRIBUTE9 ASS_ATTRIBUTE10 ASS_ATTRIBUTE11 ASS_ATTRIBUTE12 ASS_ATTRIBUTE13 ASS_ATTRIBUTE14 ASS_ATTRIBUTE15 ASS_ATTRIBUTE16 ASS_ATTRIBUTE17 ASS_ATTRIBUTE18 ASS_ATTRIBUTE19 ASS_ATTRIBUTE20 ASS_ATTRIBUTE21 ASS_ATTRIBUTE22 ASS_ATTRIBUTE23 ASS_ATTRIBUTE24 ASS_ATTRIBUTE25 ASS_ATTRIBUTE26 ASS_ATTRIBUTE27 ASS_ATTRIBUTE28 ASS_ATTRIBUTE29 ASS_ATTRIBUTE30 LAST_UPDATE_DATE LAST_UPDATED_BY LAST_UPDATE_LOGIN CREATED_BY CREATION_DATE TITLE OBJECT_VERSION_NUMBER
931510 7-Nov-08 31-Dec-12 122 (null) (null) (null) 3978 1 (null) 14402 (null) 220150 (null) 734956 (null) (null) 476 (null) (null) (null) (null) 2 E Y (null) 100035417-2 (null) (null) (null) 45948739 (null) (null) (null) (null) (null) (null) (null) 868007 (null) (null) (null) (null) 449 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null)
797386 26-Aug-08 26-Aug-08 122 (null) (null) (null) 3980 3 (null) 14402 (null) 218925 (null) 734956 (null) (null) 476 (null) (null) (null) (null) 1 E Y (null) 100035417 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) 740071 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null)
916076 26-Aug-08 31-Dec-12 122 (null) (null) (null) 3980 1 4 14402 (null) 218925 (null) 734956 (null) (null) 476 (null) (null) (null) (null) 1 B Y (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null)
797386 25-Feb-08 25-Aug-08 122 (null) (null) (null) 3980 1 (null) 14402 (null) 218925 (null) 734956 (null) (null) 476 (null) (null) (null) (null) 1 E Y (null) 100035417 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) 740071 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) -
Formula to get the latest record
Hi,
I looking to have only the last record logged displayed on my report, can any one help me with the formula ?
Sorry,
Actually to be more precise I'm looking to the latest record for each equipment (where there are many records for the equipment during the day).
Many thanks,
Andreia
Edited by: andreia silva on Dec 22, 2009 3:12 PM
Edited by: andreia silva on Dec 22, 2009 3:15 PMHi,
You could use a SQL Expression field. The following example uses the Northwind database (SQL Server) as an example.
Type the following query in the SQL Expression editor
(SELECT MAX("Orders"."OrderDate")
FROM Orders
WHERE CustomerID = Customers.CustomerID)
Then create a record selection formula:
{Orders.OrderDate} = {%datum}
{%datum} is the sql expression
When you run the report, you will see only the last order for each customer -
Continually get a message saying "We are experiencing technical difficulties, please try later" when trying to set up allowances. Not very helpful. Any ideas. I am running the latest itunes with Windows 7 Professional.
Not a solution yet, but received the following from one of the tech people I've been e-mailing back & forth with.
"I'm sorry that you have been unable to submit your podcast. The podcast submission form is currently offline. When trying to submit the podcast you will receive this message "We are Currently Experienced Technical Difficulties". Once the issue has been resolved, I would be glad to inform you.
Apple is currently working toward a resolution for the issue you have reported. You will receive an email after the matter has been investigated and further information is available."
Who knows, maybe the problem isn't with my feed after all. -
Which option do I have to select If I buy the latest iPad with cellular feature for international use? If I choose verizon can I just change the sim card and insert one from another country?
I would guess you need the A1460 model
see here
http://www.apple.com/ipad/LTE/ -
The apple coloured ball keeps appearing in photo elements 13 but not in any other programme including premier elements and organiser. I have the latest IMac with ample storage and ram
I believe I have solved the problem. I have 16mb ram so I went into photo
preferences and raised to 75% what is available for photo
I also reduced the cache from 6 to 2. The last two sessions the coloured
ball has not appeared. Hope this might be usefull to others
Rgds J McBride
On Sun, Jan 25, 2015 at 7:15 PM, Barbara B. <[email protected]> -
After loading the latest software with an update, iphone 4/ 5.0, I do not have zoom with the camera any longer, can I correct this or is it a software item?
Steve:
Welcome to Apple Communities. The Zoom feature has changed a little in iOS5. To activate the zoom, "pinch" the screen with two fingers. You will see the screen zoom and will also now see the slider that you use to see when tapping the screen.
Hope this helps.
David -
i just bought ilife11 from a friend and tried to install it but it says I need to have 10.6 or later. I have 10.5.8. Can I upgrade to the latest version with a "download" ?
entatty5 wrote:
... snow leopard, which I don't have. Do I have to go program upgrade by upgrade? I can't just go from 10.5.8 to the latest? Thanks for the help.
You need Snow Leopard before you can go to Lion...
Check that your Mac meets the System Requirements...
Snow Leopard Specs:
http://support.apple.com/kb/SP575
Lion Specs:
http://www.apple.com/macosx/specs.html -
Select statement from a join file deletes the primary records with MS Expl.
Hello,
is reality,
Select statement from a join file deletes the primary records with MS Explorer 6, Firefox not, this with a normal data provider or with a normal "select..." statement.
This is very strange, I should have a.a.s.p. a solution or workaround
Thanks, Franco.
Message was edited by:
fbiaggiPlease see the following excerpt from the online documentation.
http://docs.oracle.com/cd/E11882_01/server.112/e22490/ldr_modes.htm#SUTIL1332
Enabled Constraints
During a direct path load, the constraints that remain enabled are as follows:
NOT NULL
UNIQUE
PRIMARY KEY (unique-constraints on not-null columns)
NOT NULL constraints are checked at column array build time. Any row that violates the NOT NULL constraint is rejected.
Even though UNIQUE constraints remain enabled during direct path loads, any rows that violate those constraints are loaded anyway (this is different than in conventional path in which such rows would be rejected). When indexes are rebuilt at the end of the direct path load, UNIQUE constraints are verified and if a violation is detected, then the index will be left in an Index Unusable state. See "Indexes Left in an Unusable State". -
How to get only the latest record in a folder
Hi all,
We have an OA SIT that is not a "standard" SIT in that it does not have the traditional Begin and End date. It only has an Effective date. Is there some way I can filter this table to only give me the latest record in the series? I know how to do this in SQL, but don't see how it would be possible in the EUL.
We're trying to avoid creating database views, but at this point, I'm thinking it may be the easiest way to address this. Any other suggestions?
Thanks in advance,
JewellJewell.
Of course I'm not going to mention that I have no idea what a 'standard' SIT is compared to your basic 'non-standard' SIT ... and I have to watch my spelling of such ... but however ...
As you're most likely aware, in SQL you would get all the 'standard' SIT records first by going through the table. Then you'd go back through them all and find the most recent one.
Because of this 2 table pass, I agree that just putting the SQL code in a custom folder (as you're not using views) would make the most sense.
Russ -
I have iPad running iOS 5.1.1 and when I try to update to the latest iOS with iTunes I get "iOS 5.1.1 Your software is up to date"
It looks like some Apps I was using are no longer working properly under iOS 5.1.1Sorry, the original iPad can only be updated to IOS 5.1.1
-
Running 3.6.6. Tried 4 Beta, window was too large for monitor, couldn't resize, uninstalled. Now I have this blue bar below the menu bar in 3.6.6 that says "Downloading the latest applications" with a progress twirly, never ends. Removed 3.6.6 & reinstalled. Same problem.
== This happened ==
Every time Firefox opened
== I tried 4 beta, then went back to 3.6.6That problem can be caused by the MSN® Toolbar (Tools > Add-ons > Plugins)
See [[Troubleshooting plugins]] -
Getting the Latest Record.
Consider 2 tables TestCases and TestRun
a test Case can have multiple test runs ie. TestCaseId from the Test Case Table will map into N number of Rows in TestRuns table.
I want to do a count of all the test runs which are pass, but as there are multiple entries in TestRun against the testcaseid all the test runs are counted.
what we require is to add up Results against the latest test run.
*The TestRun table has a Run Date field.Play around with the RANK function:
SELECT RANK("D0 Time"."T00 Calendar Date") saw_0, "D0 Time"."T00 Calendar Date" saw_1, "F2 Units"."2-01 Billed Qty (Sum All)" saw_2 FROM "Sample Sales" WHERE RANK("D0 Time"."T00 Calendar Date") = 1 ORDER BY saw_1 DESC
Regards
John
http://obiee101.blogspot.com/
Maybe you are looking for
-
HELP: AVCHD Log & Transfer idle problem for iMac 27"
I just bought an Apple iMac 27" but I cannot do a Log & Transfer. I used the same SDHC card that I log & transfer succesfully in the old 24" iMac. But when I did a Log & Transfer in the new 27" iMac, I got into this: 1) FCE4 can detect the card & sho
-
JDev, XML, and XSLStylesheet
I'm working through some examples in the O'Reilly, Oracle XML Applications. I have the following in MoreoverIntoNewsstory.java package mypackage2; import oracle.xml.parser.v2.*; import java.io.InputStream; import org.w3c.dom.*; import java.net.URL; i
-
Hi all, i am having some issue in grouping columns i have some specific criteria depending on that i need to group columns. i have table as transaction_table in that i have Transaction item prom_id 296 A null sale -- prom --Source item 29
-
Hello I might be missing something to configure or verify but many times I have faced below situation : When I click on document in document library either its just opens or first save to disc and open. When I check in a document , its asking for cre
-
IMessage and FaceTime not letting me use my phone number
I restarted my phone then when I turned it back on I saw my iMessage or FaceTime wasn't logged in so I logged it in. The phone number was grey with a tack same with the email but I untacked the email. Now nothing is tacked and I can only use my email