Apex Interactive Grid how to retrieve a specific record - oracle-apex

I am retrieving my grid data using:
var ig$ = apex.region("myGrid1").widget(),
view = ig$.interactiveGrid("getCurrentView");
Now I want to check for a specific record based on 2 columns: id1 and id2 where id1 = 1 and id2 = 7
How can I do that with javascript?

You can iterate for each record like this:
//"myGrid1" should be the static id of the IG region
var widget = apex.region('myGrid1').widget();
var grid = widget.interactiveGrid('getViews','grid');
var model = grid.model;
var results = [];
model.forEach(function(r) {
var record = r;
//the name of the columns should be ID1 and ID2, if not
//make the necessary changes using "_" to represent "space"
var value1 = model.getValue(record,'ID1');
var value2 = model.getValue(record,'ID2');
if(value1 == 1 && value2 == 7) {
results.push(record);
}
})
console.log(results);
To test this code, execute it on console.
To start the console on chrome just press F12
good luck.

Related

MdxScript(Model) cslculation error in measure : A table of multiple values was supplied where single value was expected

İ want to find sufficient stock according to sale.
Measure =
VAR _date = VALUES(dateofdata)
VAR opening_date = VALUES('Stores' [Opening date])
VAR dayfornewstores = _date-opening_date
VAR _days = 28
VAR avg_sales = IF(opening_date<28,[TotalSales]/opening_date,[TotalSales]/_days)
VAR qual_days = [TotalStocks]/avg_sales
RETURN qual_days
When I use this measure in table for each store it is success. But when I want all of my stores number of days to qualify for sale in card visual there is error. How can I solve it?

DAX Power BI - addcolumns to calculated table

I have a task to compare 2 dynamic periods from the table (MOO).
Th idea is to get clients which are in both dates and compare them by 1 field (Rating_rank).
But my created field calculates max from all table, not grouping by client.
What should id do?
rate_worse_tab =
var min_dt = calculate(min('MOO'[value_day]),ALLSELECTED('MOO'[value_day]))
var max_dt = calculate(max('MOO'[value_day]),ALLSELECTED('moo'[value_day]))
var cur_cl = CALCULATETABLE(values(MOO[CLIENT_UK]),filter(MOO,MOO[VALUE_DAY]=max_dt))
var old_cl = CALCULATETABLE(values(MOO[CLIENT_UK]),filter(MOO,MOO[VALUE_DAY]=min_dt))
var combo_table = CALCULATETABLE(values(MOO[CLIENT_UK]),filter(MOO, MOO[CLIENT_UK] in cur_cl && MOO[CLIENT_UK] in old_cl))
var f_table = ADDCOLUMNS(combo_table,"Old_rate_rank",calculate(max(MOO[Rating_rank]),filter(MOO,MOO[VALUE_DAY]=min_dt && MOO[CLIENT_UK] in combo_table)))
return
f_table

How to create a new column based on previous row with DAX - PowerBI

Hi on powerBI I have something like this
Desire result is this to create another column 'is_repeat from previous row'
where it is 'True' when the current row is repeat the top row
I tried to use 'EARLIER' function to compare current row to previous but EARLIER grey out my 'index' column - not sure why
thanks in advance!
Calculated Column:
=
VAR ThisIndex = Table1[INDEX]
VAR PreviousIndex = ThisIndex - 1
VAR ThisCode = Table1[code]
VAR PreviousCode =
LOOKUPVALUE( Table1[code], Table1[INDEX], PreviousIndex )
RETURN
ThisCode = PreviousCode

SQL TO DAX Conversion

New to Power BI and needing some help on a Dax Conversion. The Date 20191130 is being passed in via a Slicer from another page So I am not sure how to Set up my dax in a such a way to read the following below:
Current Value
SELECT SUM(value) FROM Table
Where DateKey BETWEEN 20181201 AND 20191130
Previous Value
SELECT SUM(value) FROM Table
Where DateKey BETWEEN 20171201 AND 20181130
(Current Value - Previous Value)/(Previous Value)
Assuming Slicer Date is in Date format, you will have to create two different calculations:
Current Value:
Current Value =
VAR End1 = Table[SlicerDate]
VAR Start1 = DATE(YEAR(End1)-1,MONTH(End1),DAY(End1))+1
VAR End2 = DATE(YEAR(End1)-1,MONTH(End1),DAY(End1))
VAR Start2 = DATE(YEAR(End1)-2,MONTH(End1),DAY(End1))+1
RETURN CALCULATE(COUNT('Table'[Name]),'Table'[Datekey]>=Start1 && 'Table'[Datekey]<=End1)
Previous Value:
Previous Value =
VAR End1 = Table[SlicerDate]
VAR Start1 = DATE(YEAR(End1)-1,MONTH(End1),DAY(End1))+1
VAR End2 = DATE(YEAR(End1)-1,MONTH(End1),DAY(End1))
VAR Start2 = DATE(YEAR(End1)-2,MONTH(End1),DAY(End1))+1
RETURN CALCULATE(COUNT('Table'[Name]),'Table'[Datekey]>=Start1 && 'Table'[Datekey]<=End1)
If your slicer date is in numeric or text format:
Current Value:
Current Value =
VAR End1 = Date(Left(Table[SlicerDate],4),Right(left(Table[SlicerDate],6),2),right(Table[SlicerDate],2)
VAR Start1 = DATE(YEAR(End1)-1,MONTH(End1),DAY(End1))+1
VAR End2 = DATE(YEAR(End1)-1,MONTH(End1),DAY(End1))
VAR Start2 = DATE(YEAR(End1)-2,MONTH(End1),DAY(End1))+1
RETURN CALCULATE(COUNT('Table'[Name]),'Table'[Datekey]>=Start1 && 'Table'[Datekey]<=End1)
Previous Value:
Previous Value =
VAR End1 = Date(Left(Table[SlicerDate],4),Right(left(Table[SlicerDate],6),2),right(Table[SlicerDate],2)
VAR Start1 = DATE(YEAR(End1)-1,MONTH(End1),DAY(End1))+1
VAR End2 = DATE(YEAR(End1)-1,MONTH(End1),DAY(End1))
VAR Start2 = DATE(YEAR(End1)-2,MONTH(End1),DAY(End1))+1
RETURN CALCULATE(COUNT('Table'[Name]),'Table'[Datekey]>=Start1 && 'Table'[Datekey]<=End1)
Hope this helps.

Log date on cell text change in Google Sheets

I'm trying to log the date in a cell when a user tries to enter a text in another cell. To give you a clearer picture, I would like today's date to be logged in cell B1 when a user writes something in A1. I used this formula in B1:
=IF(A1="","",B1=TODAY())
but it doesn't work! Any idea how I can do this?
paste this in B1 cell:
=IF(A1=""; ; TODAY())
note: the date will change daily
_______________________________________________________
otherwise, it would be:
function onEdit(e) {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Sheet1" ) { // SHEET NAME
var r = s.getActiveCell();
if( r.getColumn() == 1 ) { // COLUMN OF ENTRY
var nextCell = r.offset(0, 1); // OFFSET +1 COLUMN
var newDate = Utilities.formatDate(new Date(),
"GMT+8", "MM/dd/yyyy"); // TIMEZONE + DATE FORMAT
nextCell.setValue(newDate);
}}}