
It’s been some time that I’m working with OData information supply in Energy BI. One problem that I virtually all the time would not have a superb understanding of the underlying information mannequin. It may be actually arduous and time consuming if there isn’t a one within the enterprise that understands the underlying information mannequin. I do know, we are able to use $metadata
to get the metadata schema from the OData feed, however let’s not go there. I’m not an OData skilled however right here is the factor for somebody like me, I work with numerous information sources which I’m not essentially an skilled in, however I would like to grasp what the entities are, how they’re related and many others… then what if I would not have entry any SMEs (Subject Matter Expert) who can assist me with that?
So getting concerned with extra OData choices, let’s get into it.
The customized operate beneath accepts an OData URL then it discovers all tables, their column rely, their row rely (extra on this later), quantity and record of associated tables, quantity and record of columns of sort textual content
, sort quantity
and Decimal.Kind
.
// fnODataFeedAnalyser
(ODataFeed as textual content) =>
let
Supply = OData.Feed(ODataFeed),
SourceToTable = Desk.RenameColumns(
Desk.DemoteHeaders(Desk.FromValue(Supply)),
{{"Column1", "Identify"}, {"Column2", "Information"}}
),
FilterTables = Desk.SelectRows(
SourceToTable,
every Kind.Is(Worth.Kind([Data]), Desk.Kind) = true
),
SchemaAdded = Desk.AddColumn(FilterTables, "Schema", every Desk.Schema([Data])),
TableColumnCountAdded = Desk.AddColumn(
SchemaAdded,
"Desk Column Rely",
every Desk.ColumnCount([Data]),
Int64.Kind
),
TableCountRowsAdded = Desk.AddColumn(
TableColumnCountAdded,
"Desk Row Rely",
every Desk.RowCount([Data]),
Int64.Kind
),
NumberOfRelatedTablesAdded = Desk.AddColumn(
TableCountRowsAdded,
"Variety of Associated Tables",
every Listing.Rely(Desk.ColumnsOfType([Data], {Desk.Kind}))
),
ListOfRelatedTables = Desk.AddColumn(
NumberOfRelatedTablesAdded,
"Listing of Associated Tables",
every
if [Number of Related Tables] = 0 then
null
else
Desk.ColumnsOfType([Data], {Desk.Kind}),
Listing.Kind
),
NumberOfTextColumnsAdded = Desk.AddColumn(
ListOfRelatedTables,
"Variety of Textual content Columns",
every Listing.Rely(Desk.SelectRows([Schema], every Textual content.Accommodates([Kind], "textual content"))[Name]),
Int64.Kind
),
ListOfTextColunmsAdded = Desk.AddColumn(
NumberOfTextColumnsAdded,
"Listing of Textual content Columns",
every
if [Number of Text Columns] = 0 then
null
else
Desk.SelectRows([Schema], every Textual content.Accommodates([Kind], "textual content"))[Name]
),
NumberOfNumericColumnsAdded = Desk.AddColumn(
ListOfTextColunmsAdded,
"Variety of Numeric Columns",
every Listing.Rely(Desk.SelectRows([Schema], every Textual content.Accommodates([Kind], "quantity"))[Name]),
Int64.Kind
),
ListOfNumericColunmsAdded = Desk.AddColumn(
NumberOfNumericColumnsAdded,
"Listing of Numeric Columns",
every
if [Number of Numeric Columns] = 0 then
null
else
Desk.SelectRows([Schema], every Textual content.Accommodates([Kind], "quantity"))[Name]
),
NumberOfDecimalColumnsAdded = Desk.AddColumn(
ListOfNumericColunmsAdded,
"Variety of Decimal Columns",
every Listing.Rely(
Desk.SelectRows([Schema], every Textual content.Accommodates([TypeName], "Decimal.Kind"))[Name]
),
Int64.Kind
),
ListOfDcimalColunmsAdded = Desk.AddColumn(
NumberOfDecimalColumnsAdded,
"Listing of Decimal Columns",
every
if [Number of Decimal Columns] = 0 then
null
else
Desk.SelectRows([Schema], every Textual content.Accommodates([TypeName], "Decimal.Kind"))[Name]
),
#"Eliminated Different Columns" = Desk.SelectColumns(
ListOfDcimalColunmsAdded,
{
"Identify",
"Desk Column Rely",
"Desk Row Rely",
"Variety of Associated Tables",
"Listing of Associated Tables",
"Variety of Textual content Columns",
"Listing of Textual content Columns",
"Variety of Numeric Columns",
"Listing of Numeric Columns",
"Variety of Decimal Columns",
"Listing of Decimal Columns"
}
)
in
#"Eliminated Different Columns"
Right here is the GitHub hyperlink for the above code.
I used this operate for preliminary investigation on numerous OData sources together with Microsoft Undertaking On-line, Microsoft Enterprise Central, some third celebration instruments and naturally Northwind pattern. Whereas it really works superb in the entire talked about information sources, for some information sources like Enterprise Central it’s not fairly useful. So be aware of that.
I used Energy Question formatter to format the above code. I simply polished it a bit to suit it to my style. Give it a go, it’s a superb instrument.
As talked about earlier, the above operate reveals tables’ column rely in addition to their row rely. On the latter, the row rely, I wish to increase a degree. If the underlying desk has plenty of columns then the row rely calculation might take a very long time.
The screenshot beneath reveals the outcomes of the fnODataFeedAnalyser
operate invoked for a Microsoft Undertaking On-line and it took a wee bit lower than 3 minutes to run.

fnODataFeedAnalyser
customized operate for Microsoft Undertaking On-lineHave you ever used this technique earlier than to analyse a dataset that you’re not aware of the construction? Do have a greater thought? Please share your ideas within the feedback part beneath.
Oh! and… by the way in which, be at liberty to alter the above code and make it higher. Simply don’t forget to share the improved model with the group.
Associated
Uncover extra from BI Perception
Subscribe to get the most recent posts despatched to your e-mail.