PowerAutomate : Get max columnvalue From dataverse table - odata

I have a Dataverse table named my_sample_table.
Inside the table I have a column named my_sample_column of type integer whose max value should be returned. Am trying to achieve this by using the List rows action provided with PowerAutomate.
Is there a filter query that can be written on the Filter rows property ? similar to what we use with SQL : max(columnname)
Or any other queries that can be included in the List rows action which will return the same result.
I know that I can iterate through the column values to get the max value using an expresion or by sorting it and getting the topmost one. But I was wondering whether there are any direct approach to it.

I would try and use a max aggregate for this column in a Fetch Xml query:
https://learn.microsoft.com/en-us/power-apps/developer/data-platform/use-fetchxml-aggregation#max

Related

Refining a Query formula with two 'where' conditions

I need to write a Query formula to pull through unique values from another sheet, excluding rows that contain certain keywords and also excluding any empty rows.
I've written this formula:
=UNIQUE(QUERY('Sheet Name'!A1:AZ,"Select A where A is not null and where not A contains 'STRING'",1))
Unfortunately this gives a VALUE error. It works with either of the 'where' clauses but not with both.
What am I missing?
You don't need to add the seconde 'Where', it just implies that you continue to add conditions into that statement:
=UNIQUE(QUERY('Sheet Name'!A1:AZ,"Select A where A is not null and not A contains 'STRING'",1))

Get Rapidminer to transpose/pivot a single attribute/column in a table

I have a table that looks like the following:
ID City Code
"1005AE" "Oakland" "Value1"
"1006BR" "St.Louis" "Value2"
"102AC" "Miami" "Value1"
"103AE" "Denver" "Value3"
And I want to transpose/pivot the Code examples/values into column attributes like this:
ID City Value1 Value2 Value3
"1005" "Oakland" 1 0 0
"1006" "St.Louis" 0 1 0
"1012" "Miami" 1 0 0
"1030" "Denver" 0 0 1
Note that the ID field is numeric values encoded as strings because Rapidminer had trouble importing bigint datatypes. So that is a separate issue I need to fix--but my focus here is the pivoting or transposing of the data.
I read through a few different Stackoverflow posts listed below. They suggested the Pivot or Transpose operations. I tried both of these, but for some reason I am getting either a huge table which creates City as a dummy variable as well, or just some subset of attribute columns.
How can I set the rows to be the attributes and columns the samples in rapidminer?
Rapidminer data transpose equivalent to melt in R
Any suggestions would be appreciated.
In pivoting, the group attribute parameter dictates how many rows there will be and the index attribute parameter dictates what the last part of the name of new attributes will be. The first part of the name of each new attribute is driven by any other regular attributes that are neither group nor index and the value within the cell is the value found in the original example set.
This means you have to create a new attribute with a constant value of 1; use Generate Attributes for this. Set the role of the ID attribute to be ID so that it is no longer a regular attribute; use Set Role for this. In the Pivot operator, set the group attribute to be City and the index attribute to be Code. The end result is close to what you want. The final steps are, firstly to set missing values to be 0; use Replace Missing Values for this and, secondly to rename the attributes to match what you want; use Rename for this.
You will have to join the result back to the original since the pivot operation loses the ID.
You can find a worked example here http://rapidminernotes.blogspot.co.uk/2011/05/worked-example-using-pivot-operator.html

Parse Query most recent objects whereKey("pageNumber", equalTo: number)

I have a Parse class called Book. Inside it is a column pageNumber.
I want to query the most recent objects for each page number. There can be more than one object with the same pageNumber which is why I only want to query the most recent object for each value under pageNumber.
So, if there are six different objects with a value of (4) under pageNumber in the class Book how would I get just the most recently created object. Not just for pageNumber (4) but for all unique pageNumbers 1-50.
For a specific page number :
You should order the result by createdAt date, and set the limit of the query to 1 :
query.descending("createdAt");
query.limit(1);
For each page number, you can either iterate on every possible page number value, or retrieve everything and iterate other the results, selecting the most recent object for the same page number (using a hash table)

rails combine parameters in controller

Hopefully this is a little clearer. I'm sorry but I'm very new to coding in general. I have multiple tables that I have to query in succession in order to get to the correct array that I need. The following logic for the query is as follows:
this gives me an array based upon the store :id
store = Stores.find(params[:id])
this gives me another array based upon the param .location found in the table store where that value equals the row ID in the table Departments
department = Departments.find(store.location)
I need to preform one last query but in order to do so I need to figure out which day of the meeting is needed. In order to do this I have to create the parameter day_of_meeting found in the table Stores. I try to call it from the array above and create a new variable. In the Table Departments, I there are params such as day_1, day_2 and so on. I need to be able to call something like department.day_1 or department.day_2. Thus, I'm trying to actually create the variable by join the words "department.day_" to the variable store.day_of_meeting which would equal some integer, creating department.day_1...
which_day = ["department.day_", store.day_of_meeting].join("")
This query finds uses the value found from the variable department.day_1 to query table Meeting to find the values in the corresponding row.
meeting = Meeting.find(which_day)
Does this make my problem any clearer to understand?
findmethod can only accept parameters like Meeting.find(1) or Meeting.find("1-xx").
so, what you need is Meeting.find(department.send("day_" + store.day_of_meeting.to_s))
Hope to help!

Fusion tables query does not fetch some

I'm having an issue on this table: 1g_ydg74ooUSBzNfQBHOIdgrOKhxZD_92In8xTDg
I'm trying to fetch some results by CODE_DEPT. I used the filter
CODE_DEPT IN ('001', '002', '003', '02A', '02B')
and only the 3 first are fetched.
Any idea what's going on ?
Cheers
Looks like CODE_DEPT is identified as a numeric column. The last two codes are not numeric and so would not match anything. If you change the column to type Text and you should be OK.

Resources