Skip to main content

Power BI — Container Types

Pulls the container type catalog — all container types defined in your Xemelgo system.


How to Set Up​

  1. Follow the setup steps to configure privacy settings
  2. In Power BI Desktop, open Transform data → Transform data
  3. Click New Source → Blank Query, then open Advanced Editor
  4. Paste the query below
  5. In the code, replace your@email.com and YourPassword123! at the top with your Xemelgo credentials
  6. Click Done and rename the query (e.g., Xemelgo Container Types)

M Query​

let
Email = Binary.ToText(Text.ToBinary("your@email.com", TextEncoding.Utf8), BinaryEncoding.Base64),
Password = Binary.ToText(Text.ToBinary("YourPassword123!", TextEncoding.Utf8), BinaryEncoding.Base64),

Token = Json.Document(
Web.Contents("https://rest.api.xemelgo.com/login", [
Headers = [#"Content-Type" = "application/json"],
Content = Json.FromValue([email = Email, password = Password])
])
)[IdToken],

FetchPage = (nextToken as nullable text) =>
let
Resp = Json.Document(
Web.Contents("https://api.xemelgo.com/graphql", [
Headers = [Authorization = Token, #"Content-Type" = "application/json"],
Content = Json.FromValue([
query = "query($n: String) {
containerTypes(input: { nextToken: $n }) {
containerTypes {
id number name description
quantity unit imagePath customProperties
}
nextToken
}
}",
variables = [n = nextToken]
])
])
)[data][containerTypes]
in [items = Resp[containerTypes], nextToken = Resp[nextToken]],

Pages = List.Generate(
() => FetchPage(null),
each _ <> null,
each if _[nextToken] = null then null else FetchPage(_[nextToken]),
each _[items]
),
All = List.Combine(Pages),
Tbl = Table.FromList(All, Splitter.SplitByNothing()),
Expanded = Table.ExpandRecordColumn(Tbl, "Column1",
{"id","number","name","description","quantity","unit","imagePath","customProperties"},
{"ID","Number","Name","Description","Quantity","Unit","Image Path","Custom Properties"})
in
Expanded

Columns Returned​

ColumnDescription
IDUnique type identifier
NumberType number
NameType name
DescriptionType description
QuantityDefault quantity
UnitUnit of measure
Image PathType image URL
Custom PropertiesJSON string of custom fields