質問

I am storing arbitrary objects (the "data" column) in a RMDB database using a format similar to the following:

<id> <object id> <object category> <creation date> <created by> <data>

all of the columns are integers or strings - but the data column is a dump of a json record

so an example row in the database would look something like:

<id> <object id> <object category> <creation date> <created by> <data>

1 abcdef123 myclassCategory 1-1-2000 me {"key1" : "value1" , "key2" : "value2" ... }

Now I am trying to create some reports using excel - I would like to create some buckets according to "object category" and according to buckets created from the "data" json key-values

I would like to use power view (or powerpivot) to parse the data column according to the json values - into new records - and then create reports, charts, histograms etc.

How is this done (parsing the data column)?

Thanks!

役に立ちましたか?

解決

After a lot of research, I found that the easiest way to solve this problem was to download an excel add on called - "data explorer"

Using this tool you can import data from a variety of sources - including raw sql databases, csv files, json records etc.

After importing the data, a wizard opens through which you can manipulate data, join tables, hide columns or even perform some logical functions on rows.

One of the greatest things I found there was an option to "right click" the column name, and then choose the option "transform" and then choose "json"

After choosing json, excel will attempt to discover the field names (I found that doesn't work perfectly - if the field names are changing, it will only be consistent with the first 100 records or so)

after transforming the data type accordingly I was able to expand those columns , perform joins, etc.

Great tool and quite fast as well

After that, I used power pivot and power view to create the reports

他のヒント

DAX is a pretty basic language, so it doesn't have any JSON expressions. So the only way I can think of to do this within PowerPivot would be to do it as string processing, basically creating a function for each output column you want that would strip away all of the other JSON. But that's horrifically inefficient, repetitive, and just downright nasty.

In my opinion, you'd be better doing some pre-processing on the content before loading it into PowerPivot. You have numerous options for this, so whatever you're most comfortable with I guess.

As far as I can tell though, I'm afraid there's nothing "out of the box" that you can do. Happy to be corrected though if anyone knows of alternatives.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top