I want to update Interactive grid Column Heading Name dynamically in oracle apex on the basis of month selected from list.
For example I have selected August from Month LOV then the column heading should be display like this.
01/MON, 02/TUE, 03/WED .............. 28/SAT,29/SUN,30/MON.
Previous Research
Code: I try to CONCATENATE date like this.
---------------For First Column Heading-----------
SELECT '01'||' / '|| TO_CHAR(:P152_START_DATE,'DAY')
FROM DUAL;
---------------For First Column Heading-----------
SELECT '02'||' / '|| TO_CHAR(:P152_START_DATE+1,'DAY')
FROM DUAL;
This is the interactive grid having column heading from 01-Aug-2021 to 31-Aug-2021.
A column header supports substitutions, so this is one solution.
Create 31 page items P152_COL1 up to P152_COL31.
Set page item for each column heading using substitution syntax (example &P152_COL1. )
Create a page process to populate the column header page items
BEGIN
FOR r IN
(SELECT TO_CHAR(TRUNC(TO_DATE(:P152_START_DATE, 'DD-MON-YYYY'),'MM') + level - 1,'DD/DY') AS wd,
TO_DATE(:P152_START_DATE, 'DD-MON-YYYY') + level - 1 as dt,
level - 1 as rn
FROM dual CONNECT by level < 32)
LOOP
--only include the days of the selected month, else print "-"
IF TRUNC(r.dt,'MM') = TRUNC(TO_DATE(:P152_START_DATE, 'DD-MON-YYYY'),'MM') THEN
APEX_UTIL.SET_SESSION_STATE('P152_COL'||r.rn,r.wd);
ELSE
APEX_UTIL.SET_SESSION_STATE('P152_COL'||r.rn,'-');
END IF;
END LOOP;
END;
Note that I assumed date format DD-MON-YYYY for the P152_START_DATE page item - adjust as needed for your project
Related
it is possible to use page item (text field) to change pagination of interactive grid?
e.q Interactive grid is divided into 10 pages and i can input number from 1 - 10 to change pagination.
Thank you in advance
Here is an example on the EMP table. I'm showing 4 rows at a time with a select list to change pages:
Create page item P106_PAGE_NO, type select list with 5 rows, return values 0 to 4.
Create Classic report with source:
select EMPNO,
ENAME,
JOB,
MGR,
HIREDATE,
SAL,
COMM,
DEPTNO
from EMP
ORDER BY ename ASC
OFFSET NVL(:P106_PAGE_NO,1) * 4 ROWS FETCH FIRST 4 ROWS ONLY
Page items to submit: P106_PAGE_NO
Create a dynamic action on change of P106_PAGE_NO with a true action of refresh the classic report region.
That should be it - change the 4 to whatever nr of rows you need. Make sure that the "Number of rows" attribute of the classic report is set to higher than the nr of rows per page you have in the query.
I am learning power BI , for one of my requirement i want to filter table based on the selected value from the slicer and show it in different slicer.
So, here there are 4 slicer and based on selection of one slicer i have to populate the data for the 2nd.
My Table Looks Like
id Name ParentId
1 A null
2 A.1 1
3 A.1.B.1 2
So, i have only 1 table where i have to search the element by id -> parentId and then populate it in the next slicer.
e.g: if We select A then in the next slicer we should show A.1 since , id --> 1(A) = ParentId --> 1(A.1)
I tried to create separate table and then link the id with parentid in the mapping section , this concept is working but not the problem is .
If we select A then in 2nd combo A.1 and A.2 is displaying , but as we click on A.1 on the 2nd combo and then try to click on the elements on 1st combo here in our case A , then the filter is not working properly .
If appending the elements from previous selection + New selection
e.g:
Slicer 1 Slicer 2
A -- (1,2,3)
B -- (4,5,6)
Now , after clicking on A[1st Slicer] it shows (1,2,3) [2nd Slicer]
After clicking on 2 [2nd Slicer] --> showing some elements in [3rd
slicer]
But, now again click on B [1st slicer] --> [4,5,6,2] (Wrong value)
since we selected 2 its appending with the new selection only if we
click on the 2nd slicer.
So, as an alternate solution I tried to filter the selected value which is measure from the table and then show it in the list.
My expression:
Table = FILTER(TableA, TableA[id] == Tableb[selectedId] )
Tableb[selectedId] --> is measure
Table = FILTER(TableA, TableA[id] == "8DE04141-E5B6-49E1-814A-ADB4C6FF5DCF" ) --> selected Id
1st statement is not showing any value but the 2nd giving me the result when i am hard coding value , please suggest me what i can do here.
i want to filter table based on the selected value from the slicer and show it in different slicer.
You don't need DAX for that. You just set up the correct relationships and set filters and slicers in the report.
I am using SQL server data base. I need to display total no of nights based on checkindate and checkout date. i am new in Power BI.
I tried by quick measure but it is not working.
You can do this in different ways - calculate the duration in the database, add custom column in M or column in DAX.
In SQL Server use select query like this:
select checkindate, checkoutdate, datediff(day, checkindate, checkoutdate) as duration from table
In M (Power Query) - click Edit queries to open Power Query editor and then Add Column -> Custom column:
Duration.Days(Duration.From([checkoutdate]-[checkindate]))
In DAX - right click your table and select New column:
Duration_DAX = DATEDIFF('Table'[checkoutdate]; 'Table'[checkindate]; DAY)
Note, that depending on your settings, you may have to use comma (,) instead of semicolon (;) in the DAX expression above.
I have a table in a Power BI data source with a column for term start and term end date (term length can be longer than a month), along with meta data on the term. I need to report on status of purchased terms as at the end of each month. As far as I can see, the best way of accomplishing this would be to create a calculated table with an entry for each month on which a term is active at its end.
For example, an entry in the original table with the following data:
TermStartDate TermEndDate PurchaseAmount
2018-01-03 2018-04-12 100
Would end up in the calculated table as follows:
MonthPurchased PurchaseAmount
2018-01 100
2018-02 100
2018-03 100
How to accomplish this? Is there a better way than creating a separate calculated table to get this data? Any help or advise is appreciated
I managed to solve this myself, I detail the required steps below for reference:
Change start and end date column data types from Datetime to Date. <- This is needed to ensure we only generate dates on day boundaries in the next step
Add custom column with the following formula:
Month = List.Select( List.Dates([TermStartDate], Number.From([TermEndDate] - [TermStartDate]) +1, #duration(1, 0, 0, 0)), each _ = Date.EndOfMonth(_) )
This generates a list of dates between start and end, then filters to only leave the dates that are at the end of a month
Expand to new rows on the new Month column (menu at the top of the column)
Use Detect Data Type option on the Month column to change the datatype from Any to Date (for some reason I cannot manually select Date, the DataType menu option is greyed out on the Month column)
I just want to sort this based on Month and year combination (that is, based on column A) ascending. How to do this in OpenOffice Calc? The sort option on month is not working because I guess the year is also appended.
Here are some data starting from A1:
Month Total
September 2011 27825
September 2010 35801
October 2011 108485
October 2010 22223
November 2011 139222
May 2012 39319
May 2011 38226
May 2010 9671
There are different solutions:
You could transform the values of column A as dates so OpenOffice / LibreOffice can sort them accordingly (see Solution 1 below);
You could split the text values into two columns (month and year separately) and sort first for year, then for month (see Solution 2 below).
Solution 1
Select the cells holding the month/year values;
Select Menu Format -> Cells... -> Numbers;
Select Date from left list;
Enter the following format code in the Format Code field: MMMM YYYY
Hit OK
With the cells still selected, select Menu Edit -> Find & Replace... or hit CTRL+H
In field Search for, enter a single dot, and in field Replace with an ampersand (&) ; hit More Options, tick Regular Expression. Select Replace all:
Select cell A1, apply sorting using Menu Data -> Sort by column A ("month").
As result, OpenOffice / LibreOffice transforms the values of column A into dates (for example, 01/09/2011 instead of September 2011). The displayed cell content will stay "September 2011" because of the custom cell format using the code MMMM YYYY. When sorting, OpenOffice / LibreOffice recognizes the dates and sorts by month/date.
Solution 2
Insert a new column next to col A for the year values: select column B, select Menu Insert -> Columns;
Select column A, select Menu Data -> Text to Columns...
In the following dialogue, select Space as delimiter, then hit OK;
Add Year as header in cell B1;
Select cell A1, select Menu Data -> Sort; select first year, then month; don't hit OK yet (otherwise the months would get sorted alphabetically), but select Options -> Custom sort order; select the months sort order. Now, hit OK.