cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

MongoDB With r

hello everybody , I connect mongodb with mongolite instead of ODBC(Because of cost).

but I got some trouble when I search in R.The data is displayed well but not work in power bi.

I try to find the what the problem make this fault.Therefore, it's array make the data list shut.Is any one encounter this situation?

 

R CODE

library(mongolite)
m <- mongo("customer",url="myurl")
customer <- m$find()

with my screenshot.The blue word are in R and other one is in power bi.

螢幕快照 2017-05-03 下午12.06.00.png螢幕快照 2017-05-03 下午12.07.04.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Helper I
Helper I

Re: MongoDB With r

I resolve my problem but itsn't work for all list.

If you had second or third nest it didn't work. I set a loop to search which column is list() and do unlist() then the error is gone!

View solution in original post

4 REPLIES 4
Helper I
Helper I

Re: MongoDB With r

I update the problem.

 

mongolite return the query data is 

id   name   belongs
1    user1   a,b,c,d(array)
2    user2   q,w,e,r(array

 but power need to convert to this list,may be need the expandID after concat the table.

 

id   name   belongs
1    user1   a
1    user1   b
1    user1   c
1    user1   d
2    user2   q
2    user2   w
2    user2   e
2    user2   r

 Did smoe buddies came across this situation?

Highlighted
Microsoft
Microsoft

Re: MongoDB With r

@RachC,

 

You can split this column to multiple rows in Power query. Please refer to the steps below.

  1. Add a custom column.
    Untitled.png
  2. column expression
    =Text.Split([belongs],",")
    Capture.PNG
  3. Expand to new rows
    Capture1.PNG
  4. Results
    Capture2.PNG

Regards,

Charlie Liao

Highlighted
Helper I
Helper I

Re: MongoDB With r

umm.. it works cool!

 

but it's specify for known column but not for all list.

And need to covert evely column from list to text (or character) .I thought itsn't great for perfomence.I plan to implement transfer function that type of list is made new Table.

 

thanks for your tutorial! 

Highlighted
Helper I
Helper I

Re: MongoDB With r

I resolve my problem but itsn't work for all list.

If you had second or third nest it didn't work. I set a loop to search which column is list() and do unlist() then the error is gone!

View solution in original post

Helpful resources

Announcements
Meet the 2020 Season 2 Power BI Super Users!

Meet the 2020 Season 2 Power BI Super Users!

Find out who's part of the program this season, and welcome the new Super Users.

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Featured Data Story of The Month

Featured Data Story of The Month

All Data Stories Gallery contributions are reviewed for each month. We select a contribution and feature the community member the following month.

Power BI Dev Camp - Developing with .NET Core

Power BI Dev Camp - Developing with .NET Core

Learn how to develop custom web applications for Power BI using .NET Core 3.1 and .NET 5.

Top Solution Authors
Top Kudoed Authors