Exclude observations that do not exist for all quarters from data source in SAS Visual Analytics - sas-visual-analytics

I want to create a filter that will exclude observations that don't have a value for all 3 quarters (Q1, Q2, Q3 of 2016) in my dataset. Here's an example of my dataset:
Identifier | Quarter | Value
ABC3456 | 2016Q1 | 145
ABC3456 | 2016Q2 | 159
XYZ874 | 2016Q3 | 226
ABC3456 | 2016Q3 | 311
The outcome, after the application of the filter should be:
Identifier | Quarter | Value
ABC3456 | 2016Q1 | 145
ABC3456 | 2016Q2 | 159
ABC3456 | 2016Q3 | 311
because XYZ874 does not have values for Q1 and Q2 of 2016.
I have experience with Advanced filters but only to include or exclude values based on one variable. Searching through this site and the internet I can't find a solution.
Please provide an answer for SAS Visual Analytics and not SAS Enterprise Guide.
Thanks in advance.

Related

Reconcile two large tables efficiently in Power BI?

As part of a migration project, I’m looking to reconcile two fact tables (high cardinality with approx 500k rows each- there are a lot of customer accounts and it has to be reconciled on a customer account basis ). There is a many-to-many relationship between customer columns in the two tables.
I am struggling to find an efficient way to output the customers that appear in both tables but have a difference in the value.
I’ve tried merge in Power Query but it is extremely slow- perhaps due to the volume and high cardinality factor.
I would welcome any advice on how to produce the desired output efficiently?
Input Table 1:
Customer | Type | Channel | Loan
Jones | A | Branch | 100
Taylor | B | Phone | 200
Taylor | B | Online | 60
Jerez | C | Online | 120
Murray | D | Phone | 90
Input Table 2:
Customer | Type | Loan
Jones | A | 81
Taylor | B | 285
Jerez | C | 80
Jerez | C | 40
Seinfeld | A | 140
Desired Output:
Customer is in both tables, but the difference is in loan:
Customer | Type1 | Loan1 | Loan2
Jones | A | 100 | 81
Taylor | B | 260 | 285
where Loan 1 is the loan stated in Table 1; and Loan 2 is the loan stated in Table 2.
Thanks for taking the time to look at this question.

Automated sorting of table after filter is selected

timestamp | product | performance | sort_quantity
--------------|------------------|-----------------------|------------------------
2020-01-01 | Product_A | high | 819
2020-03-15 | Product_A | high | 819
2020-01-01 | Product_B | low | -214
2020-03-15 | Product_B | low | -214
2020-01-01 | Product_C | high | -100
2020-03-15 | Product_C | high | -100
2020-01-01 | Product_D | low | 933
2020-03-15 | Product_D | low | 933
2020-01-01 | Product_E | high | 501
2020-03-15 | Product_E | high | 501
I insert the table above into Tableau looking like this:
(Sorry for only having it available in German)
All this works perfectly.
Now I add a filter for column performance to the report.
When I select one of the values in the filter (e.g. high) the report looks like this:
The filter function is correct but I also want that once the filter is clicked the table is automatically sorted (descending) based on column sort_quantity.
Is it possible to to do this with Tableau?
If yes how can I achieve it?
Create a string version of sort quantity and place it as the first pill on rows, to the left of Product
str([sort quantity])
Set this field to sort Descending on by Field on Sort Quantity (not the str version).
On Str sort quantity, deselect show header to hide the column.
Final view should look like this.

Is there a way to cache and filter a table locally in PL SQL?

I’m faced with having to process a table in ORACLE 11g, that contains around 5 million records. These records are speed limits along a divided highway. There is a SpeedLimitId, HighwayId and a from mile post and to mile post to depict the area that the speed limit is applied to. Currently all the records are only on one side of the divided highway and the records need to be processed to also apply them to the other side. There is a measure equation table that lets us know which range of measure on one side of the highway equal a range of measure on the other side of the highway. This allows us to calculate the measure that the speed limit event will be on the other side by calculating the percentage of the measure value in the range on measure and then finding that same percentage of the range on the opposing side. The speed limit record can be contained to one measure equation record or it can cross several of them. Base on the information in the speed limit table and the measure equation, one or more records need to be inserted into a third table.
SPEED_LIMIT
+--------------+-----------+--------------+------------+------------+-------+
| SpeedLimitId | HighwayId | FromMilePost | ToMilePost | SpeedLimit | Lane |
+--------------+-----------+--------------+------------+------------+-------+
| 1 | 75N | 115 | 123 | 60 | South |
+--------------+-----------+--------------+------------+------------+-------+
MEASURE_EQUATION
+------------+----------------+-----------+---------+-------+----------------+-----------+---------+-------+------------------+
| EquationId | NorthHighwayId | NFromMile | NToMile | NGain | SouthHighwayId | SFromMile | SToMile | SGain | IsHighwayDivided |
+------------+----------------+-----------+---------+-------+----------------+-----------+---------+-------+------------------+
| 1 | 75N | 105 | 120 | 15 | 75S | 100 | 110 | 10 | No |
| 2 | 75N | 120 | 125 | 5 | 75S | 110 | 125 | 15 | Yes |
| 3 | 75N | 125 | 130 | 5 | 75S | 125 | 130 | 5 | No |
+------------+----------------+-----------+---------+-------+----------------+-----------+---------+-------+------------------+
Depending on information in the SPEED_LIMIT and MEASURE_EQUATION table there will be a need to insert at least one but can be as many as three records in a third table. There are a dozen or so different scenarios that can take place as a result of different values in the fields.
Using the above data you can see that the SpeedLimitId 1 is noted as being on the south side of the highway, but it is currently on the north side and that it also spans the 2 equation records with the ids of 1 and 2. In this case it spans two measure ranges as a single roadway splits off and becomes divided highway. We need to split the original records into two events and add them to third processing table and calculate the new measure for the south bound lane.
SPEED_LIMIT_PROCESSING
+--------------+-----------+-------+----------+--------+
| SpeedLimitId | HighwayId | LANE | FromMile | ToMile |
+--------------+-----------+-------+----------+--------+
| 1 | 75N | North | 115 | 120 |
| 1 | 75S | South | 110 | 119 |
+--------------+-----------+-------+----------+--------+
The methodology to calculate the measure on the south bound lane is as follows:
+--------------------+----------------------------+-----------------------------+
| | From Measure Translation | To Measure Translation |
+--------------------+----------------------------+-----------------------------+
| Event Measure as % | ((120 – 120)/5) * 100 = 0% | ((123 – 120)/5) * 100 = 60% |
| Offset Measure | ((15 * 0) / 100 = 0 | ((15 * 60) / 100) = 9 |
| Translated Measure | 110 + 0 = 110 | 110 + 9 = 119 |
+--------------------+----------------------------+-----------------------------+
My concern is to do this in the most efficient way possible. The idea would be to loop through each record in the SPEED_LIMIT table, select the corresponding records in the measure equation table and then based on information from those 2 tables I would insert records into a 3rd table. In order to limit PL/SQL context switches I planned on using "BULK COLLECT and FORALL” statements to query the event table and to run the insert statements, this would allow me to do things in batches. The missing component is how to get the corresponding records from the MEASURE_EQUATION table without having to do a sql query for every record loop in the SPEED_LIMIT table. The MEASURE_EQUATION only has about 700 records in it, so I was wondering if there is a way I can cache it in PL SQL and then filter it to the appropriate records for the current SPEED_LIMIT record.
As you can probably gleamed from my question, I’m fairly new at PL SQL and ORACLE in general, so maybe I’m going about it in the completely wrong way.

Compute value based on next row in BIRT

I am creating a BIRT Report where each row is a receipt matched with a purchase order. There are usually more than one receipt per purchase order. My client wants the qty_remaining on the purchase order to show only on the last receipt for each purchase order. I am not able to alter the data before BIRT gets it. I see two possible solutions, but I am unable to find how to implement either. This question will deal with first possible solution.
If I can compare the purchase order number(po_number) with the next row, then I can set the current row's qty_remaining to 0 if the po_numbers match else show the actual qty_remaining. Is it possible to access the next row?
Edit
The desired look is similar to this:
| date | receipt_number | po_number | qty_remaining | qty_received |
|------|----------------|-----------|---------------|--------------|
| 4/9 | 723 | 6026 | 0 | 985 |
| 4/9 | 758 | 6026 | 2 | 1 |
| 4/20 | 790 | 7070 | 58 | 0 |
| 4/21 | 801 | 833 | 600 | 0 |
But I'm currently getting this:
| date | receipt_number | po_number | qty_remaining | qty_received |
|------|----------------|-----------|---------------|--------------|
| 4/9 | 723 | 6026 | 2 | 985 |
| 4/9 | 758 | 6026 | 2 | 1 |
| 4/20 | 790 | 7070 | 58 | 0 |
| 4/21 | 801 | 833 | 600 | 0 |
I think you looking at this the wrong way. If you want behavior that resembles for loops you should use grouping and aggregate functions. You can build quite complex stuff by using (or not using) the group headers and footers.
In your case I would try to group the receipts on po_number. Order them by receipt_number then have a aggregate function like MAX or LAST on the receipts_number and name it 'last_receipt'. It should aggregate on the group, not the whole table. This 'total' is available on every row within the group.
Then you can use the visibitly setting to only show the qty_remaining when the row['receipt_number'] == row['last_receipt']

How to convert the Date into Epoch in iReport and Jasperserver

I want to create a report for login history between two dates.
The login history table has the following fields:
login_date (data type is integer)
user_id (data type is integer)
Sample records
|login_date |user_id|
+-----------+-------+
|1299954600 | 105 |
|1299954600 | 105 |
|1299954600 | 105 |
|1299954600 | 105 |
|1301164200 | 114 |
|1301164200 | 106 |
|1301769000 | 110 |
|1301164200 | 106 |
|1301769000 | 106 |
|1301769000 | 106 |
|1301769000 | 106 |
|1302978600 | 102 |
|1302373800 | 112 |
|1302978600 | 111 |
|1302978600 | 111 |
|1302978601 | 111 |
Note: I have stored the login date in Epoch time.
I want to create the report for following query.
SELECT
user_id,
count(user_id)
FROM
rep_time_tracking
WHERE
login_date between 1301596200 AND 1303496940
GROUP BY 1;
I have added two parameters for run time parameter.
Example. ${FROM} and $P{TO}, value expression is Date/Time.
Now the user selects the date and time using the input I want to convert into Epoch.
How to achieve this in iReport and JasperServer?
Its pretty Simple, All You have to do is call a function on Date which is getTime() it gives you UTC time and then use it as Parameter in query.!
See the Screent Shot.

Resources