I have the following JSON that comes from PowerBI (via the Power Automate button function)
[
{
"entity": {
"Power BI values": [
{
"G-DATEMO": 4,
"G-DATEQU": 2,
"G-DATEYR": 2024,
"G-PRODUCT": "Biscuit",
"G-BAKERY": "West",
"Year Quarter Name": "2024 Q2"
},
{
"G-DATEMO": 4,
"G-DATEQU": 2,
"G-DATEYR": 2024,
"G-PRODUCT": "Bun",
"G-BAKERY": "West",
"Year Quarter Name": "2024 Q2"
},
{
"G-DATEMO": 4,
"G-DATEQU": 2,
"G-DATEYR": 2024,
"G-PRODUCT": "Bun",
"G-BAKERY": "South",
"Year Quarter Name": "2024 Q2"
},
]
}
}
]
I want to extract only the UNIQUE items for G-PRODUCT and G-BAKERY listed if its possible in separate arrays
I have tried applying a “apply to each” in side another “apply to each” but just end up with the array being full of ‘Apply_to_each_2″
Need to achieve this inside of Power Automate
2
I saved your data into an array variable:
The first step is to create two array variables to store the values you want to extract:
The next step is to create a parse json action which will describe the structure of your json that was provided. In the content, I put the sample data array that I created. The schema should look like this:
{
"type": "array",
"items": {
"type": "object",
"properties": {
"entity": {
"type": "object",
"properties": {
"Power BI values": {
"type": "array",
"items": {
"type": "object",
"properties": {
"G-DATEMO": {
"type": "integer"
},
"G-DATEQU": {
"type": "integer"
},
"G-DATEYR": {
"type": "integer"
},
"G-PRODUCT": {
"type": "string"
},
"G-BAKERY": {
"type": "string"
},
"Year Quarter Name": {
"type": "string"
}
}
}
}
}
}
}
}
}
Next, you need to create two select actions to extract the correct values for each item. it should automatically create the loop for you if you select the correct inputs:
The last step is to remove the duplicates from each array. Create a compose action for each array, and use the following expression:
2