Calculation of age using TimeStampDiff problems
Hi, I'm running a strange problem. 'âge' is not an attribute stored in our data warehouse - but is "Date of birth".I try so to dynamically calculate age based on the difference between the date of birth and whatever "date statement" the user chooses. In the business layer, I defined the age as (note that field date_key on the date dimension is actually a DATE field, not the surrogate key):
Try #1: TimeStampDiff (TSI_SQL_YEAR, birth_date, dim_date.date_key)
Try #2: TimeStampDiff (TSI_SQL_MONTH, birth_date, dim_date.date_key) / 12
Try #3: Truncate (TimeStampDiff (TSI_SQL_MONTH, birth_date, dim_date.date_key) / 12, 0)
The problem I encounter is that, when written OBIEE the SQL in the Oracle database, instead of translating the TimeStampDiff function to use Oracle "months_between", it uses ROUND (months_between), like this:
ROUND (MONTHS_BETWEEN (T48594. DIM_DATE_KEY, T48615. (BIRTH_DATE) / 12)
And the problem is, when the flare, he pipes the calculation of age. For example, I get the following for an employee with a date of birth 20 October 1967:
RPT Date Birthdate age
Jan 2009 10/20/1967 41
Feb 2009 10/20/1967 41
Mar 2009 10/20/1967 41
Apr 2009 10/20/1967 41
Apr 2009 10/20/1967 42
May 2009 10/20/1967 42
Jun 2009 10/20/1967 42
Jul 2009 10/20/1967 42
Aug 2009 10/20/1967 42
Sep 2009 10/20/1967 42
Oct 2009 10/20/1967 42
Nov 2009 10/20/1967 42
Dec 2009 10/20/1967 42
As you can see, on 20 April, the age increased from 41 to 42 years. April 20 is exactly 6 months before date of actual birth of 20 October (so the problem with the ROUND function).
I need to somehow "force" OBIEE use TRUNC (months_between), not ROUND (months_between). Well, to tell you the truth, not sure at all why he puts ROUND here... If I wanted the rounded number, I would add this feature in muself. Other creating a view in the physical layer to support this, is possible to do what I'm trying to do it directly in the business layer?
Thanks in advance!
Scott
If so...
use the functions of database directly with function evaluate in OBIEE
Tags: Business Intelligence
Similar Questions
-
IK heb 13 PSE used zonder problems maar het niet meer, naked works red squeeze mededeling PSE 13 editor works niet meer ik is een clean opgetreden. Programma en opnieuw installeren want closer niet. IK use windows 10.
Moving to Photoshop Elements
-
Calculation of days of company using TimestampDiff in OBIEE
Hi Experts,
I have a requirement to calculate working days and I use a simple statement as shown below. I need calculatethe difference between two days when 'Day of the week indicator' = 'Y' and holiday status flag = 'n'. The statement here calculates the difference between two days and I get the results displayed for each time the condition ('Day of the week indicator' = 'Y' and status of Holiday indicator = 'n') is true. Ideally, I need to pass this filter inside the TimeStampDiff function to retrieve the correct value (because consider the days of week and holidays when calculating difference in date). Please let me know on how we can move the filters inside the TimestampDiff function or if there is another way to achieve this.
BOX WHEN "CalPERS BI." "" The RPD Date2. "' Day of the week indicator ' = 'Y' and 'CalPERS BI." "" The RPD Date2. "" Indicator state holiday "= ' don't
THEN TimeStampDiff (SQL_TSI_DAY, "CalPERS BI". "" The RPD Date2. "" Calendar date ","CalPERS BI. " "' Date4 RPD. ("" Calendar Date ") END
Thank you.
Rick.
Check this http://www.cool-bi.com/Tweaks/DateExcludingWeekends.php
Try this
TimeStampDiff (SQL_TSI_DAY,
BOX WHEN "CalPERS BI." "" The RPD Date2. "' Day of the week indicator ' = 'Y' and 'CalPERS BI." "" The RPD Date2. "" Indicator state holiday "= ' don't
THEN "CalPERS BI '." The RPD Date2. "" Calendar Date "end.
BOX WHEN "CalPERS BI." "" The RPD Date2. "' Day of the week indicator ' = 'Y' and 'CalPERS BI." "" The RPD Date2. "" Indicator state holiday "= ' don't
THEN
"CalPERS BI '." Date4 RPD. ("" Calendar Date "END)
-
Problem with calculation of measurement using instruction box
Hello Experts
I have a measure that calculates the percent of sales by State - "sale by States" / "Total sales" * 100 and the requirement is when the numerator of the measure is < 11 then it should be ' *'. I tried to write a next case statement case when sales by State < 11 THEN ' *' ELSE sales by State END / "Total sales" * 100. I get an error saying incompatibility of data type of ideas how I can make it work.
Thank you
RC
Published by: user1146711 on July 12, 2012 07:39
Published by: user1146711 on July 12, 2012 09:17Hi RC,.
I used to have the same than the one that I solved it using the following statement hope, that it will aid.
BOX WHEN ((ARRAY. NUMERATORCOLUMN< 11))="" then="" '*'="" else="" concat(cast(round((((numerator="" column)/(denominator="" column))*100),1)="" as="" char(50)),'%')="">
Here the results of instruction box in the two values is * Alternatively, value (which is stored as varchar instead of the number data type).
Have, so the results are varchar. you get no data type mismatch error.That, by your statement the case... A case get varchar and another survey number which is the offset. (Logic)
I have concatenated with the '%' sign to show results under 15%, 16% and stores the same results (Varchar).
I hope that this solves your problem. Please, attribute points. :) :)
Let me know, if you still find problems.
-
I've seen a few problems I'm trying to calculate the total amount for consumption. Thus, for example: for the first 20 watts is charged at 0,40 for next 20 watts is charged at 0.80 and 0.90 for each watt exceeding 20 watt
I tried to do something on my own, but the calculation is wrong and is it possible to optimize the query because I don't want to do the math in the main select statement. subquery is a better option?
SELECT CustName, previousRead, newRead, newRead-previousRead AS Consumption,
(((newRead-previousRead-100)*FR)+((newRead-previousRead-200)*SR)+((newRead-previousRead-200)/200)*TR)as TotalBill
FROM (
SELECT C.firstName||''||C.lastName as CustName, R.newReading previousRead,
lead(R.newReading) OVER (PARTITION BY R.meterID ORDER BY R.dateVisited) AS newRead, B.firstconsumeRate as FR,
B.secondconsumeRate as SR, B.firstconsumeRate as TR
FROM reading R, address S, electricmeter W, customer C, rate A, corporaterate B
WHERE W.electricmeterID
= S . Electric meterID
AND R .electricmeterID
= W .electricmeterID
AND A . rateID = S . rateID
AND B . rateID = A . rateID
AND C . CustomerID = S . CustomerID
ET C . custType = 'corporate'
AND r . datevisit >= To_date ('01-06-2014','DD-MM-YYYY')
AND r . datevisit < To_date ('31-07-2014','DD-MM-YYYY')
)where newRead is not null;Here you go, like what Frank said that you can do using CASE.
SELECT Cust, previousRead, newRead newRead-previousRead AS consumption.
CASE WHEN newRead-previousRead<=>=>
THEN (newRead-previousRead) * EN
WHEN newRead-previousRead<=>=>
THEN 100 * FR + (100-previousRead-newRead) * SR
WHEN newRead-previousRead > 200
THEN 100 + 100 * EN * SR + ((newRead-previousRead)-200) * TR
END as TotalBill
DE)
SELECT C.firstName | "| C.lastName as CustName, R.newReading previousRead,
Lead (R.newReading) OVER (PARTITION BY R.electricmeterID ORDER BY R.dateVisit) LIKE newRead, B.firstconsumeRate like EN,.
B.secondconsumeRate like B.thirdconsumeRate like TR, SR
R reading, address meter W, S, rate A, company B, C client
WHERE W.electricmeterID = S.electricmeterID
AND R.electricmeterID = W.electricmeterID
AND A.rateID = S.rateID
AND B.rateID = A.rateID
AND C.custID = S.custID
AND C.custType = 'Corporate '.
AND r.datevisit > = TO_DATE('01-06-2014','DD-MM-YYYY')
AND r.datevisit<>
) where newRead is not null;
-
I found no useful result in the forum here with regard to the setting to calculate an age in a field based on a date of birth in another area. I'm looking for is a simple explanation to implement a PDF form to do exactly that, without the study in-depth behind Javascript itself, just to accomplish this one task.
My Acrobat application puts existing forms of paper for a municipal police force in digital format, and it would eliminate simple errors. While I'd like to dig in and learn JS, all what I need right now is the code to insert a DOB age and today's date.
Thanks for any help in this matter.
You must place this script in the "custom calculation script" for the field of 'age '.
See How to do calculations of (not so simple) form for instructions on how to enter the script.
-
PDF attached used open - problem just started
This week, a PDF file attached to an e-mail gives error message "error downloading, the download could not be saved, because an unknown error occurred - try again. On the download window, the message is "failed, resource mailbox. Yet, I can save the file to the desktop and open it.
This problem just started happening.
Help would be appreciated... Thank you in advace
Perry B
Problem solved, kind of...
I went and changed the options of attachments to use my own Adobe Reader instead of the (in Thunderbird) option. Now by clicking on the attachment in Thunderbird works fine. There must be something wrong with the drive of Thunderbird.
-
Privileged calculator HP - NORMALD_CDF and NORMALD_ICDF problem
Normal distribution functions do not work as documented. The entries are average, standard deviation and X or probability according to the function. In all cases, the functions ignore the entry of mean values and standard deviation and assumes that 0 and 1 for these values. Is there a fix for this problem?
Hello
You can post your problem here:
https://groups.Google.com/Forum/?fromgroups#! Forum/comp.sys.HP48
There are members of the team of Calculator HP that browse this newsgroup and the first is discussd it.
-
Calculation of power using Rogowski coil
Hello
I am trying to decide if I should build a VI or if SignalExpress is capable of calculating power based on my selection of transducer.
I'm trying to calculate the three-phase power of a system using a 2-wattmeter method. I have a NI cDAQ-9178, Rogowski and a winding module NI 9215.
Since the output of the Rogowski coil voltage is 90 degrees out of phase from the real wave, I can't simply multiply the voltage and current waveforms for the real power. I need to integrate the signal of the Rogowski coil and then multiplying two signals together.
Is there a SignalExpress option which allows me to integrate the signal or phase change the output voltage of Rogowski?
Thank you.
Hi Jcesar,
I think that the best way would be to incorporate them into LabVIEW, if you have this option, other wise, a way to do in SignalExpress could also be to add a step in LabVIEW on your SignalExpress project, here you can find a guide who has something similar with a numerical integration.
https://decibel.NI.com/content/docs/doc-12714
Hope that you may find useful!
-
age of the problem online empires (status code 800700e8)
I try to put the code to redeem in an era of the game online empires so I can play with the premium package, but when I do so it opens a window and says status code 800700e8... what should I do to solve the problem?
Hello
I suggest you according to the question in this forum and check if that helps:
http://www.Xbox.com/en-us/support/PCIt will be useful.
-
Using intermittent problems "invoke the node->; default reset" command to delete a table
I use the 'default' reinitalization invoke the node to clear a table after sending the data to a file. The next time that the vi is called the table should appear all items, set the default values. However sometimes the picture is not deleted and data since the previous call of the vi are still in the arrary, or at least it appears that way, since the same data for the previous time called appear in the file when new values are added to the file. New data looks good, as the data points in the table that I don't update appear with the old values. And again, it is an intermittent problem. I can solve this problem for a while in any case stop labview and re-run it. Any ideas what's happening?
Thank you.
Chuck
-
Dragon Age Orgins installation problem
Having trouble installing Dragon Age Orgins.
Says "current permissions are insufficient to write in the selected installation folder.
What does that mean?
Finally, I would like to be able to install at least one match to play.Hi Sherri R
· What operating system is installed on the computer?
You get this message if there are problems with the permissions to find out if the game is not install with administrator privileges.
Right-click on the program and click Run as administrator.
Now, check if you are able to install the program without any problem.
Thank you, and in what concerns:
Swathi B - Microsoft technical support.Visit our Microsoft answers feedback Forum and let us know what you think.
-
Hello
I'm having a little problem with the Age of mythology online...
me and my brother, we want to play against or with eachother online.
My question is: is this possible, because we have the same IP address.
When we try to play with them we always have an error.
If anyone knows how to solve this problem... Please let us know!Greetings,
Hasufal
Hello Hasufal, welcome.
What is the configuration on both of your computers. You're both in the same place or in different places?
In addition, what is the exact error message that you receive when you try to connect?
Let us know,
Thank you!
-
Stop switch 10 and use the problem
Hello
I have an Acer Switch 10 Tablet and for some time, it has had problems
When the browser (chrome or opera) is opened it would at some point become insensitive
With that the W8.1 would thus become half-don't not responding
Some features work others do not (cannot open Manager tasks and other Windows programs, but at the same time can open VLC and watch a movie, Explorer opens as well)
When I try to reboot then it will work not (hard stop only)
Wanted to use recovery utility and reinstall, but it does not open
The motherboard was broken
-
All-in-one j6480 using linux, problems during the update of the kernel
I have a platform of linux opensuse 11.0 (printer was working fine before the update) and updated the linux kernel and lost the connection to a printer, is the hpj6480 all-in-one printer, then updated to hplip 3.9.2
using auto-install in the terminal, installed latest driver hplip 3.9.2, by checking installed software packages poster old version 2.8.4 printer hplip currently works as a USB direct connect but not wireless
other than the obvious question how do I solve this problem... What is the plan for the installation of the printer basic logic (IE... direct connect USB - wireless - cable) or install also completely wireless? ... I should completely uninstall the printer and system drivers and re - install as a new system... And are there associated lib files that it removed the old driver of 2.8 and 2.10?
It turns out that the hplip should be reinstalled... but which has also compounded the problem was that the firewall should be removed to complete installation... Thank you for your help
Maybe you are looking for
-
Slow Mac - EtreCheck does not validate
My Mac worked very slow as of late and I use EtreCheck to try to identify any problems. He discovered a few Adware on my machine but I was unable to delete due to an EtreCheck error. I do not have a firewall, so I don't know why it does not work. I w
-
HI CAN SOMEONE THERE HELP ME WITH A PROBLEM WITH MY TABLET I CAN GET ON A GAMING SITE I AM ALL THE TIME ON MY LAPTOP, I TRIED TO GET THE GAMES ON MY TABLET SITE I CAN GET MY PROFILE ON THE SITE OF THE GAME WITHOUT A PROBLEM IT IS WHEN I GO PLAY THE G
-
can not start my window 7 on hp Pavilion dv7 - 6123cl
Hi all After hibernation, I couln t wake up my laptop. He gave me some ugly opinions, like intruction error 0 x 000000001200 and i/o error 0xc0000185. When I ran the test of primary hard drive colonettes, the result was "hard disk complete 1 (305). C
-
Hi, so I have this laptop for more a yaer now, and whenver I try to update my drivers through HP Support Assistant, he begins, download then says installation then it says full, but nothing is really happening. I tried many times to download Bluetoot
-
Drivers for HP Pavilion DV7 2111tx on 64-bit Windows 8
After that the things of upgrade (custom installation from 32 to 64 bits) of Windows 8 as the built in media controls did not work properly. So, I visited the drivers HP page and ran the scan... then chose Windows 7 64-bit (not Windows 8 it). The lis