Oracle Apex 22.21 - Chart Page - Bar Type - How to return a range of date values based on user input - oracle-apex

I have a table ORDERS which contains column ORDER_DATE. I have created a Chart as a Bar type.
Right now, the chart returns all the orders because I did not specify a Maximum Rows. The date on the x-axis and the number of orders on the y-axis.
How can I add a form for the user to select a range of dates and return only the values for those dates?
Example:
Doesn't necessarily have to be a calendar. A dropdown is fine as well. Or even a 'text' input since that is the easiest way.. I just need to know how to go about creating this feature. Your help is appreciated. Thank you.

First create a page item as date picker or some other plugin you already have to let users select a date or date range. (make sure that when user selects a date, the page item value is set by using a dynamic action or by a setting that your plugin has (set item value after selection kind of setting) )
Then create a new view with the source of your ORDERS table but it should have a where statement as it filters records by your page item such as:
select count(1)
from ORDERS
where order_date between :P1_DATE_FROM and :P1_DATE_TO
Set the source of the chart to this new view.
After user sets a value, refresh the chart by a dynamic action if it is not refreshed automatically.
In summary, the idea is to make your chart's source filtered by page items that users can change. Then refreshing the chart so that the new page item values are effective.

Related

Get Select list Item value in IG report column for DML operation

I have a Select list filter on the top of the page. I want its return value to get into any column which I create in IG report automatic DML process.
Suppose, Select list has a value "Step", when I add a row in IG report, that value should be saved into DB for one column which is hidden on UI.
I tried but sometimes it stores the value which I selected in Select list item as my last selection not the current one. Do I need to create Application item for this? Please help. TIA
In this case there is a table ig_tickes with a status column. On the page there is a page item P131_STATUS (select list) with values "OPEN" and "CLOSED". There is an interactive grid on table ig_tickets with column STATUS hidden. Functionality is that user selects a value from the select list and then clicks "Add Row".
Give the interactive grid a static id of "tickets"
Create a dynamic action on change of P131_STATUS with a true action of type "execute javascript code" and code:
var model = apex.region("tickets").call("getViews").grid.model;
model.getOption("fields").STATUS.defaultValue = apex.item( "P131_STATUS" ).getValue();
That's all there is to it.

What is the best way to take filter context from Power BI to Power App Edit/Write Data Form?

I am trying to take the filter context from my PBI dashboard to a Power App Edit Form. The scenario is as follows:
I have two tables:
Comments_Table:(empty until write back data is submitted)
Salesperson
Comments
Date
Value
Salesperson_Table:
Salesperson
Information
Salesperson1
1
Salesperson2
2
The Power App should allow users to Write Back data for the following columns to the Comments_Table:
Comments (free text)
Date (date)
Value (free text)
Every new entry should be a new row in the table.
The selected Salesperson should also be written back but should be set by the users' selection in a PBI filter. For instance, in the dashboard, users will be forced to select a unique salesperson, and this should filter the Power App.
I currently have two issues. I have set up a Form that makes a LookUp on a gallery which references the Salesperson table via the PowerBIIntegration.Data. Salesperson is in the form as a view text only item.
I am only able to filter to values that already exist in the Comments table (I prefilled some dummy rows) - it does not currently take the value from the Salesperson table...
Every new entry in the Edit Data Form overwrites the previous entry
for that salesperson. It should add a new of data instead...
Any ideas on how to proceed would be greatly appreciated...

Use Oracle APEX LOVs to Initialize Multiple Page Items? - APEX 21.1

I understand that the default behavior of LOVs is the following:
SELECT business_desc as display_val,
business_id as return_val
FROM businesses
This attached to a select type page item P1_BUSINESS will display a list and when a list row is selected, then assign the business_id value to the page item P1_BUSINESS.
Is there a way to build a list of values to set the value of more than one page item that are not displayed? Using the below SQL:
SELECT business_desc as display_val,
business_id as return_val,
form_type,
individual_flag
FROM businesses
Where now when a user selects something from P1_BUSINESS it sets the values of that row/record as follows:
P1_BUSINESS = business_id (like it does by default)
P1_FORM_TYPE = form_type (P1_FORM_TYPE is a hidden page item)
P1_IND_FLAG = individual_flag (P1_IND_FLAG is a hidden page item)
I know I can do this with an onchange dynamic action, but just curious if can do inside the LOV or select page item (P1_BUSINESS) declaratively.
In Shared Components > List Of Values, there is an attribute "Additional Display Columns". The help text on that screen says it all Additional display columns can be defined for item types that support multiple display columns, for example the Popup LOV. For item types that do not support multiple columns, these will be ignored. If adding additional display columns ensure that the return column is included in the column list. The return column can be set to Visible No and Searchable No if you do not want it displayed to users.
Example using emp/dept sample data:
Create a list of values on table emp with return empno and display ename. Save.
Edit the LOV and click Additional Display Columns > Select Columns. Select job as additional column.
In the IG, set Visible and Searchable to "No" and Apply Changes.
On the page, create 2 page items: P1_EMPNO (type popup LOV) and P1_JOB (type Text Field)
For P1_EMPNO, pick the LOV created above as shared component > List Of Values and add JOB:P2_JOB under Settings > Additional Output. JOB is the additional column name/alias and P2_JOB is the item it should map to.
Now when you run the page, observe that P1_JOB is populated when you select a value for P1_EMPNO

How to write a query based on the Date item, in interactive grid

I have a date field and a interactive grid. I am trying to generate the Interactive grid based on the value inputted in the date field.
I am trying to write the query as below :
select pap.effective_start_date , pap.effective_end_date
from per_all_people_f pap
where :SELECT_DATE between pap.effective_start_date and
pap.effective_end_date
Here, SELECT_DATE is the name of the Date field (datatype Date picker). I am writing a dynamic action on Change of Date field, and refreshing the interactive grid region.
But when I change the value in Date field, it doesn't return any rows.
I have done a similar change where my interactive grid was based on a dropdown. There I had to set the "page action on selection" to Submit, and it worked. But here, since it is a Date field, the "Page Action on selection" property doesn't appear on the page .
Can somebody please suggest, how can I achieve this.
You need to explicitly convert your bind variables, which are treated as strings, to dates.
to_date(:SELECT_DATE)
The format mask will come from the application properties, or you can be explicit with that, too.

Refresh Apex 5.0 chart results with different dynamic actions on same SQL query

I have created a bar chart on APEX 5.0 where my query looks like below:
select col1 as label,col2 as value from table1 where :P3_NEW_1 = col3;
here: P3_NEW_1 the page item I have created of type "Select List".
The list of values in "Select List" page item are pre-populated in the dropdown using the "Shared component" type I have created and so far this worked fine and I am able to display the results of above query by passing the value through the page item select list.
Now I need to add 2 data pickers on the same Apex page such that I should now be able to filter the results using date picker through dynamic action.
I know that using an additional button I can create a dynamic action but my problem is how do I modify the above query such that following should happen.
During the page load, once I select a particular value from the "Select List", it should display records based on the value selected from dropdown
This I already achieved using above sql query for the bar chart.
Once the bar char is displayed, I should next be able to filter and display the results using date ranges through date pickers.
Here my problem is my bar chart query is same but I need to now pass the start_date and end_date to the same above sql query which but I am not sure how to achieve this. If I add a button for dynamic action I need to select the report region which is the "bar chart" region and here my query needs modification.
Once the bar chart display the results, at the next step how do I filter the results by having the date filters with dynamic action on the same region where bar chart was displayed. How to achieve this?
You can change the query to something like this:
SELECT COL1 AS LABEL,
COL2 AS VALUE
FROM TABLE1
WHERE :P3_NEW_1 = COL3
AND (:P3_START_DATE IS NULL
OR TO_DATE(TIME_STAMP,'YYYY-MM-DD-HH24:MI:SS') BETWEEN :P3_START_DATE AND NVL(:P3_END_DATE,SYSDATE));
Where :P3_Start_date and :P3_End_date are the Start and End date pickers and TIME_STAMP is your column where you store the date.
After modifying the query you can simply add a button where at Behavior>Action select Submit Page.
This way when you click the button, the page will be submitted and chart refreshed.
If you want to take your chart to the next level you can do a partial refresh on it. Here is a short video tutorial of partial refresh on a report but you can apply the same login on your chart.