Forum Discussion
Trouble with Mongo Document that has an Array
- 6 years ago
I would suggest you connect to Mongo DB using ODBC connector and then using R script in power query to do data transform. About how to use ODBC connector, you may refer to doc below:
https://docs.mongodb.com/bi-connector/master/connect/powerbi/
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I would suggest you connect to Mongo DB using ODBC connector and then using R script in power query to do data transform. About how to use ODBC connector, you may refer to doc below:
https://docs.mongodb.com/bi-connector/master/connect/powerbi/
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- DavFount906 years agoRegular Visitor
v-yuta-msft Thank you for your reply I was originally using the ODBC connector however I'm not sure why but it only sees one of the collections from that database. I haven't found much else on that issue. Most of the comments about ODBC and Mongo people were saying stop using that and use R to query the data.
Edit: I found my problem I think with ODBC. I needed to restart my MongoSQL service and now they are all showing up. Must have created the first collection prior to the first start of the connector. Thanks. I'll work on the power query to get the data I want.
Is there any documentation you'd recommend for figuring out the power query for the data that is inside the "table" field type. I am not very familiar with R script or Power BI. (Currently searching the site)
Edit2:
So this query seems to get me the values I want from that column However it duplicates each entry for as many charges as there are and adds one charge per column.
let Source = Odbc.DataSource("dsn=MongoDB", [HierarchicalNavigation=true]), SCC_Database = Source{[Name="SCC",Kind="Database"]}[Data], CAD_Table = SCC_Database{[Name="CAD",Kind="Table"]}[Data], TransformColumnType = Table.TransformColumns(CAD_Table, {{"CAD_Charges", each {_}{0}, Value.Type(Table.Combine(CAD_Table[CAD_Charges]))}}), #"Expanded Activities" = Table.ExpandTableColumn(TransformColumnType, "CAD_Charges", {"Charges.Code", "Charges.Desc"}) in #"Expanded Activities"- Jyo272 years agoHelper II
Can you please explain how did you fetch array data from mongo?