Pulling data from Crystal Reports - oracle

My data is stored in Oracle and the only way I can run a report with it is using Crystal Reports. I have a set of data that looks like this ,,,,,,,,,,1, or ,1,,,,,,, or ,1,,,,,1,,,,1,. There are more variations.
Each one means a value is true for a record. There are about 54 'ticks/commas' What I want is all records with the one at the X spot. So for one report I may want all records in the 10th spot that have a 1. There may be other times where I want the records where the 1 is after spot 36. I agree it will pull other records but the main once I want is the X spot.
How do I get this? I tried a Like command but that does not narrow the data down far enough. I am familiar with SQL but not Crystal.
Any help would be great. TIA

In Crystal, you might try setting up a Parameter Field to hold a numeric value (1 to 54) then use that in a formula as the Record Selection. You'll be prompted to enter the parameter when you run the report.

In record selection i was initially going suggest the following which would bring back all records with 1 in the 12 spot. But this makes it hard to bring back a range.
split({yourfield},",")[12] = 1
This will bring back the same
instr({#test},"1") = 12
Then for your suggestion above you could use the following to bring back any record if it has a one in any spot after 36
instr({#test},"1") >= 37
As long as there is only one 1 in the field you can use this for other ranges as well.

Actually I don't want to disturb both answerts by Clayton Morris and CoSpringsGuy hence posting my answer.
You need to combine both the solutions to get the desired result.
Create a number parameter and provide either 1 to 57 numbers or keep just a filed to enter desired number.
Now in record selection use the formula given by CoSpringsGuy
if instr({databasefield.column},"1") = {?Inputnumber} --parameter field
then {databasefield.column}

Related

Multiple Search Key in a Matrix

I'm trying to solve this problem since some days now but it seems I have reached a dead end. Maybe someone would be able to help me.
I have two sheets. The first one contains the list of my clients and their delivery number depending of the weekday.
In my second sheet I would like to get the delivery number of the client (red cells) depending of the weekday I select (yellow cells).
I tried VLOOKUP formula, INDEX/MATCH, QUERY but I wasn't able to find a way to get the delivery number depending of the client's name and the weekday. I think the main issue is that in the first sheet the weekday is a column title.
Maybe the solution is simply to build my tables differently...
Thank you for your help
You can try something like this, assuming A2 and B2 the cells of first name and first day to look:
=INDEX(Sheet1!$1:$1000,MATCH(A2,Sheet1!$A:$A,0),MATCH(B2,Sheet1!$1:$1,0))
Or, if you want this same formula for the full column:
=byrow(A2:A,lambda(each,if(each="","",INDEX(Sheet1!$1:$1000,MATCH(each,Sheet1!$A:$A,0),MATCH(offset(each,0,1),Sheet1!$1:$1,0)))))
Also doable (are perhaps more simply) using a MAP/FILTER; with your 'Caption 1' table in Sheet1!A1:D4 and your 'Caption 2' table at the top-left of Sheet2, the following in Sheet2!C2 gives you the delivery number for a many names/days as you enter in the columns alongside:
=map(A2:A,B2:B,lambda(name,day,ifna(filter(filter(Sheet1!B2:D4,Sheet1!A2:A4=name),Sheet1!B1:D1=day))))
N.B. The IFNA blanks out errors for those rows where a Name/Day pair hasn't been entered yet. Extend the ranges in the filter to suit your real data.
all you need is simple vlookup:
=INDEX(IFNA(VLOOKUP(A9:A11&B9:B11,
SPLIT(FLATTEN(A2:A4&B1:D1&"​​"&B2:D4), "​​"), 2, )))

Automatically update formula after adding columns

My issue has been dealt with in here but I can't think thru and apply it to my formula
How to automatically update formula when inserting columns.
I would really appreciate some help here guys. Thank you!!!
This is the formula I got:
=IF($A$14=NAMES!$W2;$D15;
IF($A$14=NAMES!$W3;$G15;
IF($A$14=NAMES!$W4;$J15;
IF($A$14=NAMES!$W5;$M15;
IF($A$14=NAMES!$W6;$P15;
0)))))
After inserting three more columns it has to go to:
=IF($A$14=NAMES!$W2;$D15;
IF($A$14=NAMES!$W3;$G15;
IF($A$14=NAMES!$W4;$J15;
IF($A$14=NAMES!$W5;$M15;
IF($A$14=NAMES!$W6;$P15;
IF($A$14=NAMES!$W7;$S15;
0))))))
Upon adding 3 more columns to the right, it looks up for the value in $A$14 and if that matches the one in NAMES!$W + i where i is the row incrementing by 1, then it returns a specific column in the same row# 15, be it $D15, $G15, $J15, always jumping three columns.
The 3 columns are automatically inserted via a trigger based on date/time in GAS but I was not able to make the formula automatically update via GAS.
I'm not even sure if this is possible.
Please help!
Thank you!
I write here again because the comment is too short:
You're right!
Here's the link to the Sheet with editor access.
https://docs.google.com/spreadsheets/d/1Qkb96SgZ4dLRBebgxEiNkYiZ4sTtps-ZbBtBtE4J5os/edit?usp=sharing
So basically, whenever a new year is created or 3 more columns are added the formulas in C15, C16 and C17 be updated automatically from
C15 =IF($A$14=Dates!$A2;$D15;IF($A$14=Dates!$A3;$G15;0))
to =IF($A$14=Dates!$A2;$D15;IF($A$14=Dates!$A3;$G15;IF($A$14=Dates!$A3;$J15;0;0)))
C16 =IF($A14=Dates!$A2;$D16+$E15+$B13;IF($A14=Dates!$A3;$G16+$H15;0))
to =IF($A14=Dates!$A2;$D16+$E15+$B13;IF($A14=Dates!$A3;$G16+$H15;IF($A14=Dates!$A3;$J16+$K15;0)))
C17=IF($A14=Dates!$A2;$D17;IF($A14=Dates!$A3;$D17+$G17;0))
to =IF($A14=Dates!$A2;$D17;IF($A14=Dates!$A3;$D17+$G17;IF($A14=Dates!$A3;$D17+$G17+J17;0)))
and so on...
Daniel, I've had a try, and have found a way to get part of your answer. I believe the rest of your problem could be solved in the same way. Look at tab Test-GK in your sample sheet. Your original formula is in C15; mine is in C19.
Both update as you change the value in B14.
I've used a formula to calculate which cell is needed to be used, instead of lots of IF statements. The formula is as follows.
=INDIRECT(ADDRESS(15;(MATCH(A14;Dates!$A$2:$A$15;0))*3+1;4))
This uses MATCH to obtain an 'offset' value for your date range from in your Date values.
Then it multiplies this by 3 to jump to the right column.
So for the first date range in your list, "a 31 de diciembre 2018", MATCH returns "1" (first date range in the list) times 3 plus 1 equals "4", which ADDRESS converts to column "D". The row is always 15 using your sheet.
So ADDRESS(15,1,4) returns D15.
And INDIRECT gets the value of D15.
I think the same principle could be used for the formula in C16. But I'm not as clear what that formula is doing. Does your script put a value into B13?
Let me know if this looks useful.
Update#1. I've got the formula (I think) to replace your formula in C16 as well now. Except for the third term, adding B$13, in only the first case? If necessary, this could be handled with one IF statement, to check if the data range is "a 31 de diciembre 2018".
Let me know how the B13 value is used...
Update #2. Also added a formula to replace your IFs in C17. Effectively the same, but used a CHOOSE function to select which terms get added together, instead of an IF. Maybe a bit clearer to maintain if you add more years to the date range.
Try this formula in C17 - double check the logic.
=CHOOSE(MATCH(A14;Dates!$A$2:$A$15;0); D17; D17+G17; D17+G17+J17; D17+G17+J17+M17; D17+G17+J17+M17+P17; D17+G17+J17+M17+P17+S17; D17+G17+J17+M17+P17+S17+V17; D17+G17+J17+M17+P17+S17+V17+Y17)
It's good to 2025, but if you need another five years or so, you can just make it longer. There is perhaps a way to build it dynamically, but I didn't have the time now for that.

OBIEE remove dimension value based on measure result

One of my dimension contains the different divisions of the company. I have one division which doesn't exist anymore but I want to keep this to check the results of previous years and months.
How do I dynamically eliminate this value of the dimension when it doesn't have a measure anymore?
First I was thinking that adding a filter where the measure should be > 0 or 'not null' but this doesn't seem to do the trick. The dimension keeps showing up.
Thanks!
To go a bit into more details on Robin's question which is the most pertinent one:
Do you try to remove the "obsolete" dimension member from dimension-only queries - like prompts for example?
This is crucial to know as forcing a normally dimension-only query over a fact and thus continuously forcing the inclusion of the fact table for all queries potentially has quite a performance impact.
a) ">0" and "is not null are two completely different things and if used in a cavalier fashion can also yield absolutely wrong results. What if the measure is at a negative value? That would make it "disappear" as well for you. What if there simply is no measure yet but the dimension member is implicitly actually valid just not filled yet? That would also make it disappear for you.
b) How can you know the point of view a user is standing at? For an analysis run for last year this will be perfectly valid to show?
c) What about time-variant comparisons? What about rolling calculations?
d) What about the point-in-time of the dimension rather than the fact? --v
e) What about cross-org analysis like "What do our numbers look like when we apply last year's org vs this year's vs a planned new one which is already loaded into the data source?
While I understand the idea behind your question you should not forget that we're talking analytics here and always face changing dimensions and attributes so your request which seems valid from a human point of view for that one, specific use case is - for the solution as a whole - to be considered wisely.
Although I'm not clear on what you mean by "eliminate this value of the dimension", I think you may be looking for the pivot measure function, called FILTER(Fact USING (Insert your filter here)).
I am assuming that when aggregating using a measure, your problem is that you are unable to exclude the Division that does not exist anymore, and as a result, your measures/aggregations are incorrect.
In this case, you should use the pivot measure as I indicate above.
Your column formula would look like this:
FILTER(Measure1 USING ("SubjectArea1"."Division" <> 'DivisionName'))
Follow these steps to implement this function:
Edit the column formula of your measure.
Highlight the formula of the column and click the Filter... button at the bottom of the Column Formula text box. An Insert Filter window will appear.
Select the Division column from the Subject Areas pane. (Either double-click it, or select it then click the OK button).
You will see a New Filter window. Change the Operator to is not equal to / is not in.
Select your Division that you want to exclude.
Click OK to close the New Filter window.
Click OK again to close the Insert Filter window.
Click OK again to close the Edit Column Formula window.
If your syntax is correct, you will see no errors.

How can I get the values in the Matrix on my SSRS report to repeat?

I know there must be a simple answer to this, but I can't find it.
I have added a couple of textboxes to a Matrix in a BIDS/SSRS report. I've given these textboxes values such as:
=Fields!WEEK1USAGE.Value
It works (after a fashion); when I run the report (either on the Preview tab, or on the Report Server site) I see the first corresponding data value on the report - but only one.
I would think that once a value has been assigned via expressions such as "=Fields!WEEK1USAGE.Value", each value would display (rows would automatically be added).
There must be some property on the Matrix or the textbox that specified this, but I can't see what it might be.
Here is how my report looks (very minimalistic, so far) in the Layout pane:
...and after running, on the Preview tab:
Obviously, I want the report to display as many rows as necessary, not just one. The textboxes do have a "RepeatWith" property, but there description doesn't sound interesting/useful/promising.
I don't see any property on the Matrix control that looks right, either.
I thought maybe the designer was only showing one row of values, and ran the report on the server, too, but there also it just shows the two values.
So what do I need to do to get all the data for a provided field?
Matrices are for display of grouped data and summary information, usually in a horizontally expanding pivot table type of format. Is a matrix really what you are after? Looking at your expression you have =Fields!Week1Usage.Value but in a matrix what I expect to see would be at least =Sum(Fields!Week1Usage.Value) or even better just =Sum(Fields!Usage.Value). Then you would have ProactDescription as your row group and the week as your column group and it would all just work out everything for you, grouping and summing by Proact vertically and expanding the weeks out horizontally.
What seems to be happening is that you have no grouping on rows or columns and no aggregation so it is falling back to the default display which is effectively the First function - it displays the first row of data and as far as the matrix is concerned it has done its job because there is no grouping.
Without knowing your problem or data, I'll make up a scenario that might be what you are doing and discuss how the matrix does the heavy lifting to solve that problem. Let's say you have usage data for multiple Proacts. Each time one is used you record the usage amount and the date and time it is used. It could be used multiple times per day but certainly multiple times in a week. So you might be able to get the times each Proact is used from a table like so:
SELECT ProactDescription, TimeUsed, Usage
FROM ProactUsage
ORDER BY ProactDescription, TimeUsed
In your report you want to show the total weekly usage for each Proact over multiple weeks. Something like this:
Proact Week1 Week2 Week3 ...
Description Usage Usage Usage ...
--------------------------------------------
Anise, Fennel 1 CT 20.00 22.50 16.35 ...
St John's Wort 15.20 33.90 28.25 ...
...
and so on. Using a dataset based on the SQL above we create a matrix and in the row group properties we group on =Fields!ProactDescription.Value and in the column group properties we group on a week expression like =DateDiff(DateInterval.Week, Fields!TimeUsed.Value, Today) and then in the intersection of the row and column we put =Sum(Fields!Usage.Value). To display the header of the column nicely put an expression like
="Week " & DateDiff(DateInterval.Week, Fields!TimeUsed.Value, Today)
The matrix automatically does all the summing by week and product and expands the weeks horizontally for as many as you are reporting. For bonus points you can also put totaling at the end of the columns and the rows to show the total use of that Proact for the period (row total) and total use of all Proacts in that week (column total).

Not getting the correct totals using Cognos Report Studio. Need to get totals that show up in column

newparts_calc
if (([MonthToDateQuery].[G/L Account] = 4200 and [Query1].[G_L_Group] = 'NEW')) THEN ([Credit Amount]-[Debit Amount]) ELSE (0)
Data Item1
total([newparts_calc])
I need Data Item1 to return newparts_calc values only.
So for example in 1st row Data Item1 should be 8,540.8, but is 34,163.2
Whats wrong? how do i fix?
REVISED QUESTION
I apologize for not making sense on the original question.
I have many of the calc's that im trying to gather and put on a crosstab. I want to see sales by month (row) and part category (column)
[Query2] is the one shown in picture above.
It joins [MonthToDateQuery] AND [Query1]
The join is on 'Invoice' and carnality is 1..1 = 1..1
[MonthToDateQuery] is based on the package im working in. General ledger. It supplies the g/l entries for each sales g/l account
[Query1] is a SQL query i brought in to be able to break out categories even further from g/l group.
For example g/l account 4300 is rebuilt. However i needed to break out even further to see Rebuilt-Production and Rebuilt-New. I can do that with the g/l group.
I saw in my g/l account ledger entries that it referenced the invoice number. So thats how i tied in my SQL.
So as you can see from the table below (which is the view tabular data from query) i need a total. I have tried plugging newparts_calc into my crosstab and setting aggregation to total but the numbers still dont seem right. I dont think i have something set as it should be.
All the calc's im doing are based on single or multiple G/L Accounts and single or multiple G/L Groups.
Any Advice?
As you can see the problem seems to be duplicate invoice numbers.
How can i fix?
Couple things come to mind:
-Set the processing order to 2
-Since your calc is always a multiple and you are joining two queries, you may need to check your cardinality. Sometimes it helps to add derived queries to ensure you are working with the correct grain.
I'm obviously missing something, but if you want
I need Data Item1 to return newparts_calc values only.
just use newparts_calc, without total? That would give you proper value for row 1 -)
If you need a running-total for days (sum of values for previous days) — you should use a running_total function.
At a guess, one of your two queries is returning multiple rows for each invoice, which will cause this double counting. Look at the output of the two queries and see if that's happening. If so, then you just need to work out how to collapse that down to one row per invoice.
Per your new question - The underlying data has got to be causing the issue. Its clearly not 1:1 (note that even though this is what your stated cardinality is, Cognos does not enforce 1:1). Invoice number is not unique, GL Group is at a lower level.

Resources