Calculation for status in Archer GRC based on date - rsa

Trying to create a status field based on a number of Value Lists that users select from, but a request has been made that we check a date field for a value to ensure an estimated date has been set so that the calculation can determine if the status of the record is "In Progress", "Late" or "Not Started".

You can try using the ISEMPTY() function within your calculated field to verify that the date field contains a value. Then, use the DATEDIF function to determine if record is late or in progress.

Related

Add filter/parameter in calculated field tableau

I'm trying to create calculated field in tableau, my below query is showing valid, however I want to give filter or parameter to it. For ex: I have a field called Account number and I want my below query to show sum of all the quarters revenue on account number level.
Sum(If ([Qtr]='2019-Q1' OR [Qtr]='2019-Q2' OR [Qtr]='2019-Q3' OR [Qtr]='2019-Q4')
THEN FLOAT([Revenue]) END)
Your logic will work.
For parameter: Create a parameter with String data type, add all field names to it. Then create a calculated field based on the parameter list. Add that calculated field to row shelf then change Parameter, the above formula will be recalculated.
For Filter: You can add filter directly.
1st option:
Add Account number as row in your worksheet
Create a Parameter String with values: 2019-Q1, 2019-Q2, 2019-Q3, 2019-Q4
Update your calculated field to:
If [Qtr]='Parameter Value' THEN FLOAT([Revenue]) END
Add this field as text and the value of sum will be for only that Qtr period
2nd option:
Add Account number as row in your worksheet
Create a Parameter String with values: 2019-Q1, 2019-Q2, 2019-Q3, 2019-Q4
Update your calculated field to:
[Qtr]='Parameter Value'
Add this field to the filters and the whole worksheet will filter on that Qtr period
You can also add another parameter for the year to be more flexible on the years

Dynamic Computation in Tableau based on User Input

I have a requirement to dynamically perform computations in Tableau based on User Input.
For this purpose my basic query looks something like this:
Select some_dimension,sum(some_measure)/count(some_measure) as
some_measure_average
from table
where date = User_Input
group by some_dimension
The User_Input value should be passed based on what the user has selected and the corresponding computation should be performed based on the above query logic.Here , the Custom SQL should hit the connected Database that contains the data and display the computed data on Tableau.
Here the average is calculated based on the division of sum and count and should only be computed for the date value that has been selected.
The Custom SQL Query option in Tableau is not able to fulfill this requirement.
Not sure if we are doing it correctly.
You can create a date parameter in Tableau and pass that as your User_Input. Type your query and click "Insert Parameter". Set the parameter Data type to Date and provide a current value. Insert it where needed in your query.

Tableau - Filter/Parameter For Different Date Ranges

I am trying to set up a filter or parameter for different date ranges in Tableau, such as:
Previous Week
Previous 4-Weeks
Previous 8-Weeks
based on the most recent data in the database. Is this possible?
Edit:
I should have been more clear here.
Is it possible to only have these options in the filter and have it based on the maximum date in the database?
Update
Based on your comment and updated question, you can do it as you intend, though it isn't as straight-forward.
NOTE: I did this very quickly and with a random data set, so it will be important for you to test this thoroughly with your data set.
Steps:
Create a parameter control that the users will use to change the selected date range. I created this as a list of strings with values that I can use directly in a calculated (after simple casting):
Create a calculated field that you will use as a filter that references the selection of the parameter control. It tests to see if the difference (in weeks) between the maximum date in the view and the date of any given row is less than the value of the parameter.
Calculation: INT([Date Filter Parameter]) > DATEDIFF("week",ATTR([Date Field]),WINDOW_MAX(MAX([Date Field])))
Place the calculated field in the filter box and set it to True.
You will be able to filter your data like so:
Original Answer
Yup - that is built into Tableau.
Add your date to the filter and select the "Relative Date" option:
You can set the defaults - users can change these later:
Then just "Show Filter":

ms access autofill date field based on date of previous record

I have a table that has estimate numbers for each department on a given date (each date is a record with fields EST_DATE, DEPT1, DEPT2, DEPT3, etc.). The date is the indexed primary key (no duplicates).
When a user creates a new record I would like the date to autofill based on the last record.
So if the last estimate was for 07/02/2015, the date for the new record should autofill as 07/03/2015. Using a default value based on the current date won't work because these estimates are generated days or weeks in advance. If it matters, the format for field EST_DATE is set to "mm/dd/yyyy".
I would prefer to use the default value of the EST_DATE field itself, but I can also use event-based VBA since users will normally be entering this estimate data via a bound form.
Create a hidden textbox named, say, MaxEstDate.
Set it's ControlSource to: =Max([EST_DATE]).
Set the DefaultValue of the textbox with EST_DATE to: =[MaxEstDate].

Can you send a full result set to an SQL function?

I am working in Postgres and I need to send in a full result set with many rows and column into a stored procedure or a function. Is this possible? If so, where can I see resources for syntax?
OK this is how I have it set up without being able to send in a result set, it forces me to break out comparison logic and put it in two different spots, however my goal is to keep the actual finding the promotion logic in one place, which I have done here. This may change one day, the comparison logic is less likely to change, it is pretty standard.
Promotion Line Item Logic
-There will be triggers set on INSERT for the promo_objects, promo_buy_objects, and promo_get_objects tables, there will be an UPDATE trigger on the promo table.
-The trigger for the xrefs will call a stored procedure called set_best_product_promos that will decide which promotion is best for that object and it will then save to a new table:
promo_best_product_promos
promo_id,
object_id,
expiration_date
-The trigger for promo will call update_best_product_promos and will send in the promo_id and if active = true it will update the expiration date for that promo else it will delete all entries for that promo
The new table has been added to the promo.sql script, however the triggers and function can not be added until the function is written.
A script will run at midnight every night to delete the entries that have expired.
PSEUDO FOR cart code (application code)
Run the union query just as we are now shown_object_promotions (this gets all available promotions for the item)
Loop through results
if buy_quantity > 0
IF the quantity of the buy item in the cart is greater than or = the buy_quantity (I think c.active_items is the items in the cart)
IF get_quantity > 0
If the get item is in the cart AND it is the item sent into this function (I think c.active_items is the items in the cart)
run the get_best_product_promos function
run comparison logic
else
run the get_best_product_promos function
run comparison logic
EDIT: So I guess I could dump this cart logic as a stored procedure as well, and then make one for the comparison logic, and boom its all in stored procedures and portable and generic?
PSEUDO FOR set_best_product_promos:
-You will send in the object_id and promo_id
-You will declare all of your variables
-Go ahead an query the end date of the promo
-You will then query the promo_best_product_promos table to see if an entry exists for this product
IF exists:
RUN YOUR UNION QUERY accept this time you will have to explicitly say all the fields you want and what variables to select them into
Then loop through your query
LOOP
run get_best_product_promos
run comparison logic
END LOOP
Now take those variables you set in the crazy logic and update promo_best_product_promos
ELSE:
insert the object_id, promo_id, and end date (expiration_date) into the promo_best_product_promos table
PSEUDO FOR get_best_product_promos:
If no buy and no get quantities
If discount type = percent
calculate value of the promotion for this item to compare later
calculate the new price for the product and update the estimated unit price
If discount type = dollar
calculate value of the promotion for this item to compare later
calculate the new price for the product and update the estimated unit price
If discount type = price
calculate value of the promotion for this item to compare later
calculate the new price for the product and update the estimated unit price
If discount amount = Free
do nothing
pass
If buy quantity but no get quantity
If discount type = percent
calculate value of the promotion for this item to compare later
If discount type = dollar
calculate value of the promotion for this item to compare later
If discount type = price
calculate value of the promotion for this item to compare later
If discount amount = Free
do nothing
pass
Else (assumes there is both buy and get)
IF the quantity of the buy item in the cart is >= the buy_quantity (I think c.active_items is the items in the cart)
If discount type = percent
calculate value of the promotion for this item to compare later
If discount type = dollar
calculate value of the promotion for this item to compare later
If discount type = price
calculate value of the promotion for this item to compare later
If discount amount = Free
#Use a different var here like in select_cart_promotion - they will always get this promotion
calculate the value of the promotion for these items
do something here to ensure the get product is in the cart
Take a look at cursors.
Postgres user defined functions can be written in many languages
On the formats of input and output parameters for PL/pgSQL you can check the documentation here
Are you sure that you need to pass this to a function? I believe you could structure your functions to avoid this, functions can return tables and get get tables inside of them. If this table of yours is a query/table/view then you can use SQL inside the function to get to it (passing only parameters of other data type); if this table is the result of another function you can call the function to get to the table. What's your scenario?