Limiting an OVER statement in Spotfire - spotfire

I am creating a line chart where X=Month Y=Unique Count of Reference Numbers (coloured by the status of the Reference Number), showing the variance from the previous month. However, there is a huge spike for the first month on the chart, as this is the first instance of the data. Is there a way to limit the expression to exclude the first month?
I'm currently using this custom expression:
UniqueCount([Opportunity #]) - UniqueCount([Opportunity #]) OVER (PreviousPeriod([Axis.X]))

Best thing would be to just limit the underlying data...
Right Click > Edit > Visulization Properties
Go to the Data page
Click Edit next to the Limit data using expression section
Use an expression like [DateColumn] > Date(2017,01,31) which would exclude all data prior to Feb 1.
Otherwise, you'd want an IF() statement, likely in the latter part of your expression.
UniqueCount([Opportunity #]) - if([DateColumn] >= Date(2017,02,01),UniqueCount([Opportunity #]) OVER (PreviousPeriod([Axis.X])))

Related

Array formula with if conditions and substraction

I am searching for a formula solution that would summarize hours based on two conditions (date - column a, activity - column b). More precise, I want to summarize hours of sleep each day with array formula that would include whole column range.
The data looks like this:
When I define exact range the formula works.
{=IF(A2:A10=I$6;IF(B2:B10="Sleep";(D2:D10)-(C2:C10);0);0)}
But when I try to include whole column it returns 0.
{=IF(A:A=I$6;IF(B:B="Sleep";(D:D)-(C:C);0);0)}
Thank you!
You can use the entire column using an IF statement inside SUM or SUMPRODUCT. It ensures the time differences is only carried out on valid rows of the input data:
=SUM(IF(($A:$A=F1) * ($B:$B="Sleep"), ($D:$D + ($C:$C > $D:$D) - $C:$C),0))
Then just extend the formula to the right (notice the $-notation).
Using SUM or SUMPRODUCT directly produces an error (#VALUE!), for example:
=SUM(($A:$A=F1) * ($B:$B="Sleep") * ($D:$D + ($C:$C > $D:$D) - $C:$C))
because it doesn't filter first for valid rows where the subtract doesn't produce an error.
Here is the output:
Note: You need to try for your excel version, for O365 it works, but it has to be tested for an older version.
The calculation for time differences (the parenthesis is required):
$D:$D + ($C:$C > $D:$D) - $C:$C
Ensures that when the end date represents a time from the next day as it is in row 5, it adds 1, to consider the next day. You can achieve the same using another IF (longer but may be easier to understand):
IF($D:$D > $C:$C, $D:$D - $C:$C, (1+$D:$D) - $C:$C)
Performance: Please keep in mind #JosWoolley comments below, about performance. Usually, indicating the entire column in the formula instead of a specific range, forces Excel to check all rows (current maximum: 1,048,576). No significant impact for invoking the formula just one time, but for multiple invocations, it will be a significant impact on performance or Excel can even not respond.
Take a look at this link for some little-known insight from Microsoft. Microsoft deliberately prevents the use of entire columns in some formulas that internally use arrays:
Excel Limitations
In particular, see this paragraph.
If you designate your data as an Excel table then you could use structured referencing, as in the example below
=SUMPRODUCT(((Schedule[End]+(Schedule[Start]>Schedule[End]))-Schedule[Start])*(Schedule[Activity]="Sleep")*(Schedule[Date]=I6))
but you should recognise that the organisation of your data does not permit the (by-date) analysis you require, e.g. most of the sleep attributable to Jan 22nd is properly attributable to Jan 23rd but that can't be reflected in the summary, as you have treated the end time on Jan 22nd as being 16 hours before the start time...
(cells I7:K7 have the custom number format [hh]:mm)

How to Generate a Burndown by Month

I have a dataset of action tracking records with due dates. I've been asked to generate a burndown curve, which I can do pretty simply in Excel, but I'm stumped on how to put this in a WebI report.
I created a variable to convert the due date for the records to yyyy-MM, so I can group them by the month they're due and count them. Then, I was able to add a runningsum of those counts in my crosstab.
[
The element that I'm missing is being able to refer to the total count of records (the total outside the column grouping of the crosstab) to subtract the running sum from.
Suggestions?
You need to deal with Calculation Contexts in order to do this. Here are a few good resources...
Removing the Confusion from Calculation Contexts
Calculation Context Part I: Overview
The More Things Change... (de facto Part II to Part I above)
To answer your question and show my work I created a free-hand SQL query using the SQL in this dbfiddle. Put into a crosstab with a running sum I get what you have in your example...
Next I created a variable called Var Report Total defined as...
=Sum([Act Count]) In Report
Then I created another variable called Var Remaining to calculate the difference...
=[Var Report Total] - [Var Running Sum]
And there you have it...

NetSuite saved search filter records with min quantity

How do I apply following requirement in Saved Search criteria?
Filter all inventory items
Where min( {memberitem.quantityavailable} / {memberquantity} ) <> custitem_quantity
Note: custitem_quantity is a custom numeric field.
Note2: NetSuite is throwing error when I use min function in filters.
There is more than one issue here.
You have to be careful with custom numerics in Netsuite.
When your inner condition evaluates, it does not have the same type because it is fractional. At some point it has to be rounded and / or truncated internally. The other side of the expression would need to call a floor or ceiling function to remove everthing past the decimal.
Also, the min function evaluates after the <> conditional, which will be dependent upon whether your custom numeric is type compatible to begin with.
In the expression you provided us, it would have to be an exact match (and an exact type), and that is before you consider whether MIN gets to be evaluated.
Look at how the datatypes are cast and what columns you are processing because memberitem.quantityavailable may need a secondary index depending upon your dependencies and where the formula is being called. If this formula is being used over multiple products, it may not be logically consistent.
When I have similar items in inventory that I want to generate stats for I try to process it separately, even if I have to make a second pass.
What are you trying to isolate exactly - - I cannot think of a quantity-related situation where there would be a need to use division in this way - - please refer to the formula Mike Robbins listed above for a properly structured evaluation and see if it achieves the desired result.
If you post the rest of your code, I will help you resolve this.
The entire expression is not valid and will not evaluate due to the conditional shown, the MIN, nor the division. Index the count on the memberquantity if you are looking to sum over values. Otherwise, CountIF will work for quantities. MIN will only finds the lowest value in a given column, so SumIF appears to be what you are after. You can create a second expression which bounds the values you are searching for as a preliminary step.
I am new here, so please elaborate on what you are trying to accomplish so I can earn the bounty.
You may want to take into account null values as well to avoid errors or inconsistent data.
If you're using formula numeric, try this:
Formula(Numeric):
case when min((NVL({memberitem.quantityavailable},0) / NVL({memberquantity},0)) - (NVL{custitem_quantity},0)) then 1 else 0 end
'IS EQUAL TO' 1
I believe you can use the Formula Text or Formula Numeric Search Filter for that.

Spotfire: How to use trellis to show 4 elements: 3 years + set of records older than 3 years?

Lets say I have the data about some kind of requests.
I have column determining request's creation date.
I wish to show the requestes Trellis'ed by this date but not the standard way.
I wish all the requests with creation date older than 2013-01-01 to be grouppped in one trellis graph.
I also would like to retain the possibility to have information on both year and quarter level as it is available for typical date column.
The image below show sth similar to what I need but the Empty section comes as the last one and I need it with different label and on the left hand side rather than as it is now on the right hand side.
Any ideas ?
my suggestion is to make two visualizations. you can duplicate the one you've already created and then limit its data by editing the properties for that vis, viewing the Data page, and using the Limit data using expression field, giving an expression like [Date Column] < "2013-01-01". you'd do the same on the second vis except use an expression like [Date Column] >= "2013-01-01".
the easiest way to change (Empty) to "something" is to not leave it empty :) you can create a calculated column with the expression If([Column] is null, "Custom Empty", [Column]) and then use that on the horizontal axis. alternatively you can hide (Empty) values from a visualization by limiting the visualization by an expression like [Column] is not null.
you can adjust the order which values are shown by going to the Edit menu and choosing Column Properties. choose the column, click the Sort Order tab, select Custom Sort Order, and click Configure.

Crystal Reports - my formula works, but when repeated in more than 1 subreport, all records disappear

I'm not a developer but I'm supposed to create a report by C.R., so excuse me in advance if it is an obvious question for you, and please keep in mind that I'm a real beginner.
I have a job composed of 3 different workings (3 out of 5, which is the maximum workings I can have for a job).
In my SQL database, the table.field corresponding to those workings is job.phase, so when I put, in my report details, the field "job.phase", I get 3 rows for that job.
The point is that my report printout always has to show 5 different text objects (one below the other), corresponding to the descriptions of all the 5 possible table.field-records, and a 'X' should appear next to text objects when each one of the workings listed there is a part of my job (otherwise nothing should appear).
What I have done is the following:
- created a subreport containing the "job.phase" field
- put it near my first text object
- specified in my subreport the following "show string" formula:
if job.phase = 'working1' then 'X' else ''
and it works: a X appears if working1 is part of my job, nothing appears if working1 is not part of my job.
Then I have created 4 subreports more, equal to the first one, and specified the same for job.phase = working2, working3, working4 and working5, BUT, after doing that, no X is shown (even though working 1, 2 and 3 are part of my job)...
Is there anybody who can help me, please? It's so frustrating...
Using subreports for something like this is overkill for what you're trying to do and could be causing any number of things to behave badly. I'd recommend you abandon that idea. Here's how I would do it:
The first thing you'll want to do is group by job (if more than one will appear in your report, which I'll assume it will). The Group Footer section is where you can display the labels and Xs. You'll need to create 5 formulas as you did before if {job.phase} = "working1" then "X", one for each of the phases/workings. Drop all 5 of those formulas into the Details section of the report and then suppress that entire section so that it doesn't display.
To show the Xs, you can use a Maximum summary in the Group Footer for each of the five formulas you created. To do this, right-click each of the formulas in turn, select Insert -> Summary. Choose Maximum as the summary, and "Group 1" (Your job ID or whatever field you are using to group the job) as the Location. That will insert a field into the Group Footer that will display an X when that particular working is specified for the job, otherwise it won't display anything. Move them to display next to the appropriate label/text field and you're done.

Resources