Result of Calculated Field as Criteria?
I'm using CASE and CAST to convert a field to datetime format so that I can account for null field values
CASE
WHEN ISDATE([Date])=0 THEN 01/01/1900
ELSE
CAST([Date] as datetime)
END as [DateConverted]
How can I use this new [DateConverted] field in the criteria of my query so that I can only get records in a specific date range?
I prefer using the below approach for date range comparison
DECLARE @tmp TABLE (Id INT IDENTITY(1,1),[Date] VARCHAR(20))
INSERT @tmp SELECT 0
INSERT @tmp SELECT GETDATE()-1
INSERT @tmp SELECT GETDATE()
INSERT @tmp SELECT GETDATE()+1
--SELECT * FROM @tmp
SELECT * FROM (
SELECT Id,CASE
WHEN ISDATE([Date])=0 THEN 01/01/1900
ELSE CAST([Date] AS DATETIME)
END [DateConverted]
FROM @tmp ) tmp
WHERE [DateConverted] >='1900-01-01'
AND [DateConverted] <'2014-01-05'
Reason being there's a small chance of some records getting wrongly excluded/included when you use BETWEEN clause especially when datetime field stores time part also.
http://visakhm.blogspot.in/2012/12/different-ways-to-implement-date-range.html
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
Similar Messages
-
Calculated Field to get Total Number of Records does not work
Hi,
For some reason, calculated fields aren't working in my business rule.
What I did:
In deficiency criteria, I added the calculated field "Total Val".
In conditions and calculations I chose "Grouping/Aggregation".
For Select Group Fields, I chose "Plant and Material Number".
For Aggregation Method, I chose "Count".
Result when "Apply Rule" is used:
The filtered records are still shown. The "Field Names" (names within the table such as MATNR instead of material number) are shown instead of the field labels.
I'm trying to determine the cause of this issue and how to resolve it. Does anyone have a suggestion of what it is and what can be done?Hi Arif,
Thank you for the response.
Is there a way we can further pin down the ABAP problem that is being experienced?
Best Regards,
Raphael -
DAX Dynamic Banding | Calculated Member based on Calculated Field
Good morning,
I've created a Power Pivot model that measures the blood glucose levels of clinical patients at specific times of the day. The requirement is that this metric, let's call it GlucoseLevel, is always averaged as it wouldn't make sense to sum up the values.
To meet this first requirement, I set the "Summarize By" property of the GlucoseLevel column to "Average".
The second requirement is to band the GlucoseLevel values so that groups of people can be measured by this band rather than by the individual measure values. I created a banding table in Excel and then imported it into the Power Pivot model. The banding table
has three columns (BandName, MinValue and MaxValue) and has the following values:
VERYLOW: Min Value = 0; Max Value = 3.99
OK: Min Value = 4; Max Value = 6.99
WARNING: Min Value = 7; Max Value = 10.99CRITICAL: Min Value = 11; Max Value = 30.00
It is at this point where I face my challenge. I have a GlucoseLevel measure and I have a banding table. Great. The challenge is: How do I create a calculated, dynamic
member that will look at my GlucoseLevel measure (at whatever level), do a lookup to my banding table, and then return the "BandName" column from the Banding table at that specific level? So to clarify what I mean by level: I want to be able
to view the bandings at Year level, or a Month level, or even at a week level. Then depending on what level I am at, my measure should have a Band associated to it.
I've tried to solve this issue in a couple of ways:
Attempt 1
Create a calculated column in my fact table that contains a nested IF statement to manually band my GlucoseLevel values. This works fine if I view my data at the lowest level of granularity, however
it does not work if I start looking at my data at the day, week, month etc. levels
Attempt 2
1.) Create a calculated field (not a calculated column) that averages my GlucoseLevel measure. This is cool because it will average my measure at whatever level I am viewing it at. Let's call
this field Bob...
2.) Band my measure Bob by creating another calculated field (called PatientBand). This field uses my banding table (described earlier) in conjunction with my calculated field Bob. This works perfectly, except for one big flaw: Excel sees this banding field
as a measure, and not as something that I can use as a column / row...
So my question is: Can I trick Excel into viewing my PatientBand calculated field as an attribute, and not as a measure? And if not, how do I get around this challenge? Here is the DAX formula that I used to create my second calculated field "PatientBand":
PatientBand:=CALCULATE(
VALUES (Bandings[BandName]);
FILTER (
Bandings;
Test[Bob] >= Bandings[MinValue]
&& Test[Bob] <= Bandings[MaxValue]
Thanks!So there are 2 ways that I can think of for doing that.
1) if you are only using MDX clients like Excel or Reporting services you can create a text based measure that returns the banding name. (Note that this sort of approach does not work at the moment with PowerView as it only displays numeric measures). This
would effectively let you show a label next to a reading as opposed to moving the reading under a given banding column.
Banding Name :=
CALCULATE (
VALUES ( Bands[BandName] ),
FILTER (
Bands,
[Average of GlucoseReading] >= Bands[BandMin]
&& [Average of GlucoseReading] <= Bands[BandMax]
&& NOT ( ISBLANK ( [Average of GlucoseReading] ) )
2) This next approach will show the results exactly as you had them in your sample screenshots. It just takes a slight bending of the DAX. I'm using a SUMX here, not because I want to sum anything, but because the "X" version of SUMX basically loops over
every row in the specified table and sums the expression in the second parameter. I have setup the second parameter so that it only returns a single value for the average if it is in the appropriate banding.
Banded Average:=IF (
HASONEVALUE ( Bands[BandName] ),
SUMX(
'Bands',
IF (
NOT ( ISBLANK ( [Average of GlucoseReading] ) )
&& [Average of GlucoseReading] >= MIN ( Bands[BandMin] )
&& [Average of GlucoseReading] <= MIN ( Bands[BandMax] ),
AVERAGE(Readings[GlucoseReading]),
BLANK()
,AVERAGE(Readings[GlucoseReading])
http://darren.gosbell.com - please mark correct answers -
New Calculated field question. Complicated I think.
I have managed to create this table from a MySQL database: http://ppbm5.com/DB-PPBM5.php
The field 'Total' is a calculated field using this SQL query:
$query_Recordset1 = 'SELECT *, `Disk I/O`+`MPEG2-DVD`+`H264-BR`+IFNULL(`MPE On`,`MPE Off`) As Total, `CPU`*`Cores` As Phys_Cores FROM `Personal_data` WHERE 1 ORDER BY (`Disk I/O`+`MPEG2-DVD`+`H264-BR`+IFNULL(`MPE On`,`MPE Off`)), `Date & Time` ASC';
So far, so good, but as you may have noticed, there is a next field called 'Rel. Perf.' which only contains blanks. And that is where my problems start.
The table is sorted by 'Total' and the first record shows these figures and field names that are relevant for my question:
Fields: 'Total' 'Disk I/O' 'MPEG2-DVD' 'H.264-BR' 'MPE On' 'MPE Off'
Values: 131, 67, 21, 37, 6, 64
In addition, I use four 'weight' figures, let's say these are 0.27 , 0.30 , 0.20 and 0.23 denoted as W1, W2, W3, W4.
First step is to calculate four temp values, using a formula like this resulting in T1, T2, T3 and T4:
T1 = W1 x Total /Disk I/O; T2 = W2 x Total/MPEG2-DVD ; T3 = W3 x Total/H.264-BR ; T4 = W4 x Total/(IFNULL(MPE On, MPE Off)
Note that this only applies to the top record and here the SUM(T1, T2, T3, T4) results in 131, equal to the Total.
The result of 100 x SUM(T1, T2, T3, T4)/ Total = 100 should be the 'Rel.Perf.' result for the top record.
Now is gets difficult. Let me call the records R1, R2, R3, ..., Rx. Now, in the previous step we have established that the figure 100 should into R1.
For R2 the result of the 'Rel.Perf.' is 100 x SUM(T1 x Disk I/O(2), T2 x MPEG2-DVD(2), T3 x (H.264-BR(2), T4 x (IFNULL(MPE on, MPE Off)))/ Total(2)
For R3 the result of the 'Rel.Perf.' is 100 x SUM(T1 x Disk I/O(3), T2 x MPEG2-DVD(3), T3 x (H.264-BR(3), T4 x (IFNULL(MPE on, MPE Off)))/ Total(3)
etcetera for all the rest of the records in the table.
A complicating factor is that the reference point of the top machine should remain fixed at 100, but when doing queries, the top machine may not be in the query results, but all the query results for the Rel.Perf. should be derived from these scores. Life would be infinitely easier if one would be certain that the top machine is fixed, but that is not the case.
Sorry to make this such a long and complicated post, but for those who have struggled through this long message, if you have any suggestions on how to make this work, I would appreciate it.
Thanks in advance.
Harm, while non is intended.
PS. I have been trying to generate a SQL query, using the following code:
$query_Recordset1 = 'SELECT *, FORMAT(`Disk I/O`+`MPEG2-DVD`+`H264-BR`+IFNULL(`MPE On`,`MPE Off`),0) As Total, FORMAT((54.661*`Disk I/O`+161.25*`MPEG2-DVD`+71.66666*`H264-BR`+645*IFNULL(`MPE On`,`MPE Off`))/129,1) As RPI,`CPU`*`Cores` As Phys_Cores FROM `Personal_data` WHERE 1 ORDER BY 54.661*`Disk I/O`+161.25*`MPEG2-DVD`+71.66666*`H264-BR`+645*IFNULL(`MPE On`,`MPE Off`), `Disk I/O`+`MPEG2-DVD`+`H264-BR`+IFNULL(`MPE On`,`MPE Off`) ASC';
For static work it is OK, but not when a new top performer submits his data.Hi William,
Per my understanding that you want to count the number of the value in the field wait which is smaller then 15, right?
I have tested on my local environment and that you can add the calculated field (Count) using the expression as below:
=IIF(Fields!wait.Value<15,1,0)
Insert an outside group row and then get the total count by using below expression:
=SUM(Fields!Count.Value)
Preview you will get the result like below:
If your problem stil exists, please try to provide some sample data and the exprect count result you want.
Any problem, please feel free to ask.
Regards
Vicky Liu
Vicky Liu
TechNet Community Support -
Problem with Math In Calculated Fields
I am calculating a group incident rate for data returned from
a query. The formula is Number of cases multiplied by 200000
divided by number of hours worked. Cases in my report is the
calculated field: calc.CaseSum (the sum of cases for the group)
Hours is calc.SumHours (the sum of hours for the group). The actual
values for these variables (for the first group are 48 and 29427171
respectively. When I create the following calculated field called
rate using the formula: (calc.CaseSum * 200000) / calc.SumHours,
Cold Fusion Generates a Runtime Error:
Invalid ColdFusion expression in report. If the expression is
a string, ensure that it is within quotes. Error: (calc.CaseSum *
200000) / calc.SumHours is not a valid ColdFusion expression.
If I use the constant value "29427171" as the divisor, the
report works albeit only for the first group. Any ideas; is this a
bug, or am I misusing the product?
Addition: I forgot to mention I am using CF8. Also this
formula worked fine as a Report Total before I introduced grouping
and modified the calculated fields to reset on the change of a
group.Sorry, I've been on another project for awhile. This problem
will certainly be a "show stopper" for me if I cannot resolve it.
As I mentioned in my original post, I used a constant in the
formula in lieu of the variable and the calculation worked. This
would suggest that CF does not have a problem with a large number.
In spite of that reasoning, I tried Tony's suggested (thanks
by the way!) with the identical outcome, only difference is the new
formula is displayed in the error message.
Tony, you also suggested that I set the variables using
CFSET... How would I do this within the report writer environment.
I had tried a similar approach: to perform half the calculation
i.e. that within the parenthesis, and assign that value to a
separate "calculated field: and then perform the rest of the
calculation on that variable with the same outcome.
I think that I may be dealing with a CF bug here, I'd like to
find a workaround... I've noticed that CF8 has a new patch, perhaps
after I apply it, I may be able to get this thing to work. I'm on
another project right now so it will be a few days before I can
test this theory, I report the result.
Should this fail, and no one can come up with a workaround, I
will report this to Adobe. -
Issue with Duplicate Results and Summary Fields
My report is based on an Access Database. For the purposes of this current issue, there is the Master Table called u201CCnu201D and then a related u201CTable Au201D which includes multiple records related to the Master and also a related u201CTable B,u201D also with multiple records related to the Master.
For my report, I want to output results from Table B based on criteria in Table A. This naturally produces duplicate output on the report. As a result, the Summary Fields that I want to include are incorrect.
I have tried multiple combinations of the Select Distinct function, suppression based on u201Cprevious fieldu201D being equal, summary fields, running totals and if-then statements and still cannot find a solution that works in all of the cases involved.
Below are descriptions of three different scenarios that are occurring:
EXAMPLE #1: Entry 1 has 2 records in Table A and 2 Records in Table B so "Select Distinct" including the Table B ID # and then a Summary Field for the Total produces the correct results, while a Running Total is Incorrect.
EXAMPLE #2: Entry 2 has 2 records in Table A and 1 Record in Table B so a suppression formula of the field based on the "Previous =" Table B ID # and the Running Total produce the correct results, while Summary Field is incorrect.
EXAMPLE #3: Entry 3 has 6 records in Table A and 6 Records in Table B. Neither Summary or
Running Totals produce correct results.
I would greatly appreciate any advice in terms of creative formulas, etc. that would help produce correct results here.
Iu2019ll be pulling my hair out soon! Thanks so much-Hi Berry
Try to create a command with a subquery. The subquery will be returning the the duplicate records and the main query that uses this subquery will find distinct records out of the resultset returned by the subquery.
Let me know if this helps.
Regards
Nikhil -
How to avoid duplications making a SUM calculated field
Hi, I'm trying to resolve this problem;
In my dataset (in a custom folder on the administrator) I have a list of tickets (with some attributes), and some of them are duplicated:
For example
Ticket_id Group_id Ticket_date Resource_name Ticket_status
5416 100000401 10/12/2007 7:10:31 am Mr. A 2
5416 100000401 9/1/2008 11:00:44 pm Mr. A 2
57381 100000401 27/12/2007 11:37:11 am Mr. A 2
57381 100000401 15/1/2008 9:33:12 am Mr. A 2
I want this duplication because I need it when I filter the dataset (using the Ticket_date) with two parameters:
Ticket_date between lower_limit_date and upper_limit_date
So, inside the report, regarding the ticket's number, if I take 2 records with the same ticket_id, I have a calculated field where I use the COUNT_DISTINCT and for each couple of tickets the count is always =1; in this way (inside the report) I have the following fields:
Group_id Count_tickects Resource_name
100000401 2 Mr. A This is OK !
Now, if I want to count how many tickets have the status = 2 (it means they are closed), I want to obtain 2 and NOT 4
I tried to use this calculation (Tickets Closed): SUM(CASE WHEN "Tickets Report #7 COMPL".Ticket Status Id = 2 THEN 1 ELSE 0 END)
but I always had the result of 4...and this not correct, because the tickets are only 2...
I also tried to use some analytic function using the OVER PARTITION BY, but I didn't obtain the correct result
In other words I'd like to achieve this:
Group_id Count_tickects Tickets Closed Resource_name
100000401 2 2 Mr.AAny help will be appreciated
AlexHi Rod, thanks for the reply,
I tried this calculation
COUNT_DISTINCT(CASE WHEN "Tickets Report #7 COMPL".Incident Status Id = 2 THEN 1 ELSE 0 END)
but it retrieves 1; it's right, because the result of the CASE statement is always 2 (the Ticket_status is always 2, 4 times), but this is not what I expect.
I'd like to calculate how many tickets are effectively opened (Ticket_status = 2) and this result is *2*, because I have only 2 ticket_id (5416 and 57381); the problem is that inside the data set these two ticket_id's are repeated two times.
I can't use "Hide Duplicate Rows" because this is only a layout solution (behind I have always the duplication); I can't use more than one aggregate function together because I have the error: Nested aggregate functions are not allowed...
To resolve this problem, I think, I have to restrict the records which are processed by the CASE statement; instead of pass to the calculation all four records (twice the ticket_id 5416 and twice the ticket_id 57381) I have to pass only two records (one the ticket_id 5416 and once the ticket_id 57381).....but how....???
Alex -
SSRS Using WHERE in a calculated field
Hi All,
Im having a real issue with something that seems like it should be easier than it is.
In my tablix I want to add the expression =Sum(Fields!ID20.Value)-Sum(Fields!ID20.Value) BUT I need to determine if another criteria is met.
EG - I want =Sum(Fields!ID20.Value WHERE [InOut]="In")-Sum(Fields!ID20.Value WHERE [InOut]="Out")
Many Thanks for any helpHi LB79,
In Reporting Services, Aggregate functions cannot be used in calculated field expressions, since the data for calculated fields will be based on individual rows not on group basis. As a workaround, we can directly add the expression to a textbox of the tablix
instead of using that calculated field. For detail information, please refer to the following steps:
Right click the text box which you want to insert the calculated field, then click Expression.
In the Expression text box, refer to the following expression:
=sum(iif(Fields!InOut.Value ="In", Fields!ID20.Value,0),"DataSet_name")-sum(iif(Fields!InOut.Value ="Out", Fields!ID20.Value,0),"DataSet_name")
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Running total of calculated field in pivot
VERSION: ORACLE 11
TABLE:
create table chart_detail (
DIS NUMBER,
BLD_MO VARCHAR2(7),
BLD NUMBER(10),
RPLC NUMBER(10));DATA:
insert into chart_detail values (60,'2011-03',0,2);
insert into chart_detail values (150,'2011-04',10572,0);
insert into chart_detail values (120,'2011-04',26449,5);
insert into chart_detail values (30,'2011-04',0,1);
insert into chart_detail values (60,'2011-04',0,7);
insert into chart_detail values (90,'2011-04',0,9);
insert into chart_detail values (120,'2011-05',5714,0);
insert into chart_detail values (90,'2011-05',24557,1);
insert into chart_detail values (60,'2011-05',0,4);
insert into chart_detail values (30,'2011-05',0,0);
COMMIT;EXPECTED RESULTS:
2011-04 2011-05
DIS RPLC BLD TBLD IPTV RPLC BLD TBLD IPTV
30 1 0 37021 0.03 0 0 30271 0.00
60 7 0 37021 0.22 4 0 30271 0.13
90 9 0 37021 0.46 1 24557 30271 0.17
120 5 26449 37021 0.59 0 5714 5714 0.17
150 0 10572 10572 0.59 0
180 0 0
TOTAL 22 37021 5 30271 PROBLEM: I need to have a running total of IPTV like in the above example. I can get the IPTV for each DIS/bld_mo but I don't know how to get the running total of it. In the script below I just used an example where I tried summing the IPTV like was done for build. I know it can't be done that way because IPTV is a calculated field in the query but if I substitute "APR_IPTV" with the formula for IPTV I get an error that window functions aren't allowed here. I do not know a way around this. I commented out the bad piece of code.
PROBLEM SCRIPT:
WITH pivot_results AS
SELECT dis
, NVL (apr11_rep, 0) AS apr11_rep
, NVL (apr11_bld, 0) AS apr11_bld
, NVL ( SUM (apr11_bld)
OVER (ORDER BY dis DESC)
, 0
) AS apr11_tbld
, DECODE(NVL ( SUM (apr11_bld)
OVER (ORDER BY dis DESC)
, 0),0,0,ROUND(NVL(apr11_rep, 0)*1000/ NVL ( SUM (apr11_bld)
OVER (ORDER BY dis DESC)
, 0),2
)) AS apr11_iptv
, NVL ( SUM (apr11_iptv)
OVER (ORDER BY dis DESC)
, 0
) AS apr11_tiptv
, NVL (may11_rep, 0) AS may11_rep
, NVL (may11_bld, 0) AS may11_bld
, NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0
) AS may11_tbld
, DECODE(NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),2
)) AS may11_iptv
, DECODE(NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),2
)) AS may11_tiptv
FROM chart_detail
PIVOT ( MAX (rplc) AS rep
, MAX (bld) AS bld
FOR bld_mo IN ( '2011-04' AS apr11
, '2011-05' AS may11
SELECT CASE
WHEN GROUPING (dis) = 0
THEN TO_CHAR (dis)
ELSE 'Total'
END AS dis
, SUM (apr11_rep) AS apr11_rep
, SUM (apr11_bld) AS apr11_bld
, SUM (apr11_tbld) AS apr11_tbld
, CASE
WHEN GROUPING (dis) = 0
THEN SUM (apr11_iptv)
END AS apr11_iptv
, SUM (apr11_tiptv) AS apr11_tiptv
, CASE
WHEN GROUPING (dis) = 0
THEN SUM (apr11_tpiptv)
END AS apr11_tiptv
, SUM (may11_rep) AS may11_rep
, SUM (may11_bld) AS may11_bld
, SUM (may11_tbld) AS may11_tbld
, CASE
WHEN GROUPING (dis) = 0
THEN SUM (may11_iptv)
END AS may11_iptv
FROM pivot_results
GROUP BY ROLLUP (dis)
ORDER BY pivot_results.dis
;Thank you,Hi,
So you know how to compute iptv for an individual row; the problem now is that you want to get a running total of iptv; is that it?
The problem there is that computing iptv requires an analytic function, and analytic functions can't be nested. To get the results of nesting f (g (x)), where f and g are analytic funtions, you have to compute g in a sub-query, and then use the results as the argument to f in a super-query.
Here's how to apply that to your situation:
WITH pivot_results AS
SELECT dis
-- April, 2011
, NVL (apr11_rep, 0) AS apr11_rep
, NVL (apr11_bld, 0) AS apr11_bld
, NVL ( SUM (apr11_bld)
OVER (ORDER BY dis DESC)
, 0
) AS apr11_tbld
, NVL ( 1000 * apr11_rep
/ NULLIF ( SUM (apr11_bld) OVER (ORDER BY dis DESC)
, 0
, 0
) AS apr11_iptv
-- May, 2011
, NVL (may11_rep, 0) AS may11_rep
, NVL (may11_bld, 0) AS may11_bld
, NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0
) AS may11_tbld
, NVL ( 1000 * may11_rep
/ NULLIF ( SUM (may11_bld) OVER (ORDER BY dis DESC)
, 0
, 0
) AS may11_iptv
FROM chart_detail
PIVOT ( MAX (rplc) AS rep
, MAX (bld) AS bld
FOR bld_mo IN ( '2011-04' AS apr11
, '2011-05' AS may11
SELECT CASE
WHEN GROUPING (dis) = 0
THEN TO_CHAR (dis)
ELSE 'Total'
END AS dis
-- April 2011
, SUM (apr11_rep) AS apr11_rep
, SUM (apr11_bld) AS apr11_bld
, SUM (apr11_tbld) AS apr11_tbld
, CASE
WHEN GROUPING (dis) = 0
THEN ROUND ( SUM (SUM (apr11_iptv))
OVER (ORDER BY dis)
, 2
END AS apr11_iptv
-- May 2011
, SUM (may11_rep) AS may11_rep
, SUM (may11_bld) AS may11_bld
, SUM (may11_tbld) AS may11_tbld
, CASE
WHEN GROUPING (dis) = 0
THEN ROUND ( SUM (SUM (may11_iptv))
OVER (ORDER BY dis)
, 2
END AS may11_iptv
FROM pivot_results
GROUP BY ROLLUP (dis)
ORDER BY pivot_results.dis
;Output:
APR11 APR11 APR11 APR11 MAY11 MAY11 MAY11 MAY11
DIS _REP _BLD _TBLD _IPTV _REP _BLD _TBLD _IPTV
30 1 0 37021 .03 0 0 30271 .00
60 7 0 37021 .22 4 0 30271 .13
90 9 0 37021 .46 1 24557 30271 .17
120 5 26449 37021 .59 0 5714 5714 .17
150 0 10572 10572 .59 0 0 0 .17
Total 22 37021 158656 5 30271 96527As you can see, this is not quite what you wanted on the row where dis='150'. You asked for NULLS in the may11_rep, may11_bld and may11_iptv columns. You can get those results if you need them; just explain the rules that govern whether to display the values and when to display NULL.
The way you posted the sample data and results, and the quantity of sample data were all excellent; it really helped me find a solution. Thanks.
It would have also helped it you had explained how iptv is computed. Basically, iptv = 1000 * rep / tbld, right?
It looks like most of this code:
, DECODE(NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
OVER (ORDER BY dis DESC)
, 0),2
)) AS may11_iptvwas a way of avoiding divide by 0 errors; it would have been helpful if you had explained that. -
Problem with the query of Sharepoint Calculated Fields
Hello,
I am developing an application in sharepoint 2013 foundation. but i have problems with a list, when executing a caml query on a calculated field. I try the solution of this blog
http://sptalks.wordpress.com/2013/03/25/query-on-calculated-field-problem
but i got no result
attentive to any comments
thanksHello,
This is my CAML Query
<View>
<ViewFields>
<FieldRef Name="ID" />
<FieldRef Name="PermMask" />
<FieldRef Name="FSObjType" />
<FieldRef Name="Nombre" AutoHyperLink="TRUE" />
<FieldRef Name="Apellidos" AutoHyperLink="TRUE" />
<FieldRef Name="Cargo" /><FieldRef Name="Edad" />
<FieldRef Name="Compa_x00f1_ia" />
<FieldRef Name="Created" />
</ViewFields>
<Query>
<GroupBy Collapse="TRUE" GroupLimit="30">
<FieldRef Name="Compa_x00f1_ia" />
<FieldRef Name="Edad" />
</GroupBy>
<OrderBy>
<FieldRef Name="ID" />
</OrderBy>
<Where>
<Contains>
<FieldRef Name="Ano" LookupId="FALSE" />
<Value Type="Text">2014</Value>
</Contains>
</Where>
</Query>
</View> -
Hi,
To begin with I am just learning EJB and JAVA so please bear with me. I want to create a calculated field in a query from two fields in the table being queried, using SQL I would write the query like this:
SELECT ledgerdate, description, quantity, unitprice, [quantity*unitprice] FROM ledger
I have created a class called ViewLedger to contain my results, it has the following elements:
DATE ledgerdate,
STRING description,
INTEGER quantity,
BIGDECIMAL unitprice,
BIGDECIMAL amount
The query that I have been attempting that fails is:
SELECT NEW ViewLedger(l.ledgerdate, l.description, l.quantity, l.unitprice, l.quantity*l.unitprice) FROM Ledger l
The error says that there is an unexpected * in the query
The following do not work either:
SELECT NEW ViewLedger(l.ledgerdate, l.description, l.quantity, l.unitprice, (l.quantity*l.unitprice)) FROM Ledger l
The error says there is an unexpected ( in the query.
SELECT NEW ViewLedger(l.ledgerdate, l.description, l.quantity, l.unitprice, [l.quantity*l.unitprice]) FROM Ledger l
The error says there is an unexpected [ in the query.
Any help would be greatly appreciated.
Thanks.I don't think JPQL allows functions (*) in the SELECT clause.
You can use a native SQL query as a workaround. If you are using EclipseLink or TopLink Essentials, you can also use a ReportQuery.
You may also want to vote for the bug,
[https://bugs.eclipse.org/bugs/show_bug.cgi?id=219814|https://bugs.eclipse.org/bugs/show_bug.cgi?id=219814]
James : [http://www.eclipselink.org|http://www.eclipselink.org] -
Trouble with calculating fields. Can't select (check) fields. Also can't figure out what's wrong with a division field (percent) that I created. Keep getting the pop up that format of the field doesn't allow blah blah blah... Help!
1. Use the mouse to select the field and then press the space bar.
2. A null string is the same as zero. What is the result for division by zero? -
Date VS Date Time in Calculated Field
I have a property for a patients records called Date of Birth. On the table defining it I saved it as a "date" type and It displays only
the date on the screen as I would like. For some reason though when I needed a calculated field in the Medication record I added a property to the patient records table that concatenated two fields BirthDate and the Age. I used the following code and then
added an other screen data item on the medication screen to pull the DoBA property up but got a Date/Time instead of just a Date.
partial void DoBA_Compute(ref string result)
// Set result to the desired field value
result = "DoB:" + BirthDate + " Age:" + Age;
//This is for the property "Date of Birth and Age"
//I also used the following code to calculate "Age"
partial void Age_Compute(ref int result)
// Set result to the desired field value
int age = DateTime.Now.Year - BirthDate.Year;
if (BirthDate > DateTime.Now.AddYears(-age)) age--;
result = age;
ImagesI'm using cast instead of Convert.ToInt because the last round to value to upper int if value > 0.5 or to lower if value < 0.5 ( I don't remember now if equal goes to < or > ... read function doc ) while Cast to int do not round the value.
In my code the day of the birthday
still
marks
the
previous
age,
from the
day after
one more year.
by adding
+
1
age
increases
by the
day
of the birthday -
Calculated Field formula not appearing in Power View Field List panel
Hi,
On Power View1 sheet of this
workbook, the two PowerPivot calculated Field formulas (First Visit and First date of FY) are not appearing in the Power View Fields panel on the right hand side.
I want to drag client and First Visit (calculated Field) to the Power View.
Why is this happening?
Regards, Ashish Mathur Microsoft Excel MVP www.ashishmathur.comI found a workaround for it - I was having the same problem as you. I wanted to display the last refresh date of my data, but Power View wouldn't display a date resulting from the [Last Refresh]=MAX(Date[Date]) formula.
HOWEVER, a Pivot Table can handle that Calculated field just fine. So I renamed my measure "Refreshed Date" and added another tab in the Excel Sheet. I added a Pivot Table from PowerPivot into cell A1 and the only thing I put was that single
measure (A2). To the right of that, I did =A2 and created an Excel Data Table. The title of that was "Last Refresh". Now, I could add that Data Table to the PowerPivot Model and into Power View. And then I hid that tab.
The only downside to this method, is that if you're refreshing single tables at a time, you have to remember to refresh the Pivot Table when new data is added AND update the data in the model. I'm only connecting to one database, so I just choose
"Refresh All" in Excel and it updates everything. It works perfectly! :)
Well shoot, I even took a screenshot that helped explain everything, but it won't let me post it because my account isn't verified and it won't tell me how. If you have any questions, please let me know and I'll clarify! -
Copying a Calculated Field Value to another Field in the same List
Hello! I have a calculated field that uses an if statement to determine a score. IE A field called Downtime Score contains this calculate: IF Downtime Minutes =10, 100. (not correct formatting, just basic to get point across)
I simply want to use a workflow to copy the calculated value in Downtime Score (100) to another field called Final Downtime Score.
In the workflow, I current have the following: Set FinalDowntimeScore to CurrentItem:Downtime Score
When I log both to workflow history, they both show 0 in history. Nothing is copying.
The calculated field is a number and I tried both number and text fields for FinalDowntimeScore.
This is within SharePoint 2013 and using SharePoint Designer 2013.
Any help would be appreciated!Ok, I did the same test as you and it failed. I still return a 0 when I should see a 100.
Not sure if this helps but when even though we are using sharepoint designer 2013, we only have "SharePoint 2010 Workflow" available in Platform type when creating workflows.
Could you test again using SharePoint 2010 workflow as your platform type and see if you return the same results?
Thanks!
Maybe you are looking for
-
Problem with motherboard and cpu cooler
First of all , hello. Let me present my current pc. Mainboard - MSI 880GM-E41 CPu - Amd phenom x2 560 black - unlocked to quad Ram - 4 gb kingmax DDR 3 Video - Gainward GTS 450 512 DDR 5 Hdd - Western Digital 640 GB Power suply - Sirtech 400 W Now th
-
I uninstalled iTunes because it kept shutting down. I figured the best thing was to start over. After uninstalling iTunes, when I went to load the newest version 10.5 it wouldn't finish the installation telling me to log on as the administrator. I'm
-
my iphone4s has been restart...then something asking about delete from iphone? i tap it..then till now its been rebooting for hours..please help
-
Problem while sending the message using RWB
Dear All, I am facing a problem while sending a message from RWB. I sent the message using Test Message in component monitoring, it says message sent but I am not able to see any message in sxi_monitor. When I send the same message using the http cli
-
How can i separate 4 files to individual files that are on 1 email?
How can I separate 4 files to individual files that are all on one email?