'Powerbi Nosql filtering embedded array documents
I have a report collection in cosmos DB like below.
{
"_id": {
"$oid": "62053aa9aa1cfbe8c4e7268b"
},
"school": "school1",
"reports": [
{
"year": "2020",
"createdAt": {
"$date": "2022-02-11T06:30:06.514Z"
},
"reportId": {
"$oid": "6206026e0f1e3a778f323a37"
},
"data": {}
},
{
"year": "2020",
"createdAt": {
"$date": "2022-02-11T10:44:03.960Z"
},
"reportId": {
"$oid": "62063df3dadaff633e46afee"
},
"data": {}
},
{
"year": "2021",
"createdAt": {
"$date": "2022-02-14T08:46:42.485Z"
},
"reportId": {
"$oid": "620a16f28fc7d7f884b3a7ce"
},
"data": {}
},
{
"year": "2021",
"createdAt": {
"$date": "2022-02-14T09:08:33.486Z"
},
"reportId": {
"$oid": "620a1c11f3ecd888b6648ff8"
},
"data": {}
},
{
"year": "2021",
"createdAt": {
"$date": "2022-02-28T11:46:15.552Z"
},
"reportId": {
"$oid": "621cb607637ce7b74183a912"
},
"data": {}
}
]
},
{
"_id": {
"$oid": "62053aa9aa1cfbe8c4e7269e"
},
"school": "school2",
"reports": [
]
}
I just want to get the data of school reports in the Power BI. But in the reports embedded array, I would like to show the latest report of all the years by referring the createdAt field. My sample output should be like this below,
{
"_id": {
"$oid": "62053aa9aa1cfbe8c4e7268b"
},
"school": "school1",
"reports": [
{
"year": "2020",
"createdAt": {
"$date": "2022-02-11T10:44:03.960Z"
},
"reportId": {
"$oid": "62063df3dadaff633e46afee"
},
"data": {}
},
{
"year": "2021",
"createdAt": {
"$date": "2022-02-28T11:46:15.552Z"
},
"reportId": {
"$oid": "621cb607637ce7b74183a912"
},
"data": {}
}
]
},
{
"_id": {
"$oid": "62053aa9aa1cfbe8c4e7269e"
},
"school": "school2",
"reports": [
]
}
Is there any way Could I achieve this kind of data fetching in Power BI?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
