What would be a correct PowerQuery syntax to extract the information from this Web JSON into a table:
I'm not very familiar with PowerQuery, and this is probably the only time I'll need this, so I'd be grateful if someone would help me out without refering me to documentation. Thanks
[{"time_entry_group": {"minutes": 301,"time_entries_params": {"locked": "0","from": "2021-02-01","to": "2021-02-28","customer_id": "11223344","project_id": "223388","service_id": "435248"},"revenue": 57691.6666666667,"project_id": 223388,"project_name": "Scrb","service_id": 435248,"service_name": "Meetings","month": "202102"}}
, {"time_entry_group": {"minutes": 1175,"time_entries_params": {"locked": "1","from": "2021-01-01","to": "2021-01-31","customer_id": "11223344","project_id": "223388","service_id": "421393"},"revenue": 225208.333333333,"project_id": 223388,"project_name": "Scrb","service_id": 421393,"service_name": "Design","month": "202101"}}
, {"time_entry_group": {"minutes": 24,"time_entries_params": {"locked": "1","from": "2021-01-01","to": "2021-01-31","customer_id": "11223344","project_id": "3168911","service_id": "95033"},"revenue": 4600.0,"project_id": 3168911,"project_name": "youkn Dev","service_id": 95033,"service_name": "Reviews","month": "202101"}}]
For future reference, if you have a column that you need to expand, you can instead click this arrow icon to the right of the column name. Clicking it should display a menu that should then allow you to specify which nested columns you want to get expand or get at. To be clear, it will expand that column for all rows in that table, not just one.
The JSON you've included is basically an array of objects, so maybe use:
Json.Document to parse the JSON, which should give you a list of records
Table.FromRecords to turn the list of records into a table.
Table.ExpandRecordColumn to expand a nested record columns.
Example implementation:
let
json = "[{""time_entry_group"":{""minutes"":301,""time_entries_params"":{""locked"":""0"",""from"":""2021-02-01"",""to"":""2021-02-28"",""customer_id"":""11223344"",""project_id"":""223388"",""service_id"":""435248""},""revenue"":57691.6666666667,""project_id"":223388,""project_name"":""Scrb"",""service_id"":435248,""service_name"":""Meetings"",""month"":""202102""}},{""time_entry_group"":{""minutes"":1175,""time_entries_params"":{""locked"":""1"",""from"":""2021-01-01"",""to"":""2021-01-31"",""customer_id"":""11223344"",""project_id"":""223388"",""service_id"":""421393""},""revenue"":225208.333333333,""project_id"":223388,""project_name"":""Scrb"",""service_id"":421393,""service_name"":""Design"",""month"":""202101""}},{""time_entry_group"":{""minutes"":24,""time_entries_params"":{""locked"":""1"",""from"":""2021-01-01"",""to"":""2021-01-31"",""customer_id"":""11223344"",""project_id"":""3168911"",""service_id"":""95033""},""revenue"":4600,""project_id"":3168911,""project_name"":""youkn Dev"",""service_id"":95033,""service_name"":""Reviews"",""month"":""202101""}}]",
parsed = Json.Document(json),
initialTable = Table.FromRecords(List.Transform(parsed, each [time_entry_group])),
expanded = Table.ExpandRecordColumn(initialTable, "time_entries_params", {"locked", "from", "to", "customer_id"})
in
expanded
One thing about the code above is that it doesn't expand nested fields project_id and service_id (present within time_entries_params). This is because these columns already exist in the table (and having duplicate column names would cause an error). I've assumed this isn't a problem, as the nested values aren't different.
If I have
grid-template-columns: 20vw 20vw 20vw 20vw;
But only 3 items, can I get the 3 items to center ignoring the 4th space? Or is that the wrong tool for this job and I should use another method like flexbox.
I am new to power bi and would require your help to sort out below issue which I am facing.
Basically I am taking three columns into consideration as below:
Question: I would like to remove duplicate values from above table based on conditon "
Equal value for "Time" ,"ID" and Absolute difference in "Time spent" is lower or equal than 1"
as you can see in the image Rows highlighted falls in this category.
I would like to get these below rows removed based upon condition.
Question: I would like to remove duplicate values from above table based on conditon "
Equal value for "Time" ,"ID" and Absolute difference in "Time spent" is lower or equal than 1"
as you can see in the image Rows highlighted falls in this category.
I would like to get these below rows removed based upon condition.
I am able to perform this in excel by making us of a fourth column with formulae =IF(AND(A3=A2,B3=B2,ABS(F3-F2)<1),"problem",0) and then filtering out the rows marked as probelm. Please help!!
Regards
Mahi
I bet the suggestion from #Alexis Olson works just fine, but since you specifically mentioned the Query Editor, here's how I would do it there:
Have your data loaded like below, and just accept the changes made under Changed Type:
Don't worry about the other steps under the Query Settings. We'll get to that eventually.
Select Add Column and click Index Column, so that you get this:
Select Add Column, click Custom Column and insert this little formula in the appearing dialog box Table.AddColumn(#"Added Index", "Custom", each #"Added Index"[Time Spent]{[Index]}-#"Added Index"[Time Spent]{[Index]-1}):
Click OK, and make sure that you're getting this:
I think this step is a little weird, but you'll have to click 'Table' there in the column:
You will get an Error message in the first row, but you can remove that by right-clicking that column, and clicking Remove Errors:
Now you can click the drop-down menu in the Custom Column, select Number Filter and Does Not Equal
And insert 0, or select 0 from the drop-down menu in the dialog box:
This is it, your required numbers should now be filtered away:
Note, however, that this procedure comes at a cost since you're losing the first value due to the first step in the indexing. If the rest of this is something you can use, I can see if we can fix that last little part as well.
You can pick a representative [Time Spent] value from each unique set of rows by taking a max or min over the list of "duplicate" values. Here's the formula for such a custom column, which I'll call [Min Time]:
= List.Min(
Table.SelectRows(#"Previous Step",
(C) => (C[Time] = [Time] and
C[ID] = [ID] and
Number.Abs(C[Time Spent] - [Time Spent]) < 1)
)[Time Spent])
Once you have this custom column, you can group by [Time], [ID], and [Min Time] to roll up the duplicates and then rename the [Min Time] column to [Time Spent].
My question is how do i replace an item in a listbox in Lazarus from a button procedure?
I know how to add and delete an item thats selected within the listbox but how do i remove the selected item and then add another item in the same place as the old one without changing its position in the listbox.
Example:
Bowl
Collar
Large pack of chews
Medium pack of chews
Pet grooming kit
Tick shampoo
Vitamin supplement
If i wanted to remove 'Collar' from the listbox and replace it with another item like 'Cat food' and have Cat food in the second index position.
Any help would be appreciated.
Assuming that you know that the index is 1 then you can replace that item's text with a simple assignment:
ListBox1.Items[1] := 'Cat food';
I am a DBA of 7 months so please bear with me. I am needing to write a code that will find a particular ProductIdentifier. When this particular ProductIdentifier is found, 1. I need to grab this ProductIdentifier. 2. I need to go 2 rows up and place that ProductIdentifier in the field that is 2 rows above it.
Here is my code(everything is sorted properly already in this table)
SELECT
SipID,
SaleInvoiceID,
AssociationNumber,
Priority,
TotalPrice,
TotalCost,
SerialNumber,
ContractNumber,
ActivatedThroughPAW,
DateCreatedatMidnight,
ReceivedDate,
InvoiceIDByStore,
Location,
ProductIdentifier,
Description,
ShortDescription,
CategoryName,
RevenueStreamID,
RevenueType
FROM REVISEDTABLE.
I will better show you what needs to be done ![enter image description here][1]
ProductIdentifier
AWUPG2001RGP -- replace this product identifier with the 'AWRPNS000%'
POSC0021PRW
AWRPNS000343 --take this product identifier
What I need for this code to do is this: whenever I find any ProductIdentifier like 'AWRPNS000%', I need for the query to take this and go 2 rows up and replace whatever ProductIdentifier is in this with 'AWRPNS000%'. I then need to insert the results into a table. I believe the best thing to do is to select the ProductIdentifier row again and give it an alias. This will be the row that I need to transform. I can then do a comparison to see if things worked out. I do not know how to write the code to do the actual grabbing of the ProductIdentifier and going up 2 rows and replacing it, so any help or input would be greatly appreciated.
So what does two rows up mean. Why is it two rows up.
e.g.
ID Class Type Date
1 1 2 20/12/2012
2 1 2 21/12/2012
3 1 2 22/12/2012 *
ie yes ID is two rows up but that's because The records are in ID and date order and there are at least three of them.
If you can come up with that rule e.g.
Select * From SomeTable Where Class = 1 and Type = 2 And Date = 20/12/2012
Then all your problems go away...