Dashboard Mode - OData and REST API connections
Business Question
How can we connect Power BI to online data sources using OData and REST API to create a live sales dashboard?
How can we connect Power BI to online data sources using OData and REST API to create a live sales dashboard?
Data is fetched live from an OData feed and a REST API providing sales orders and customer info.
| OrderID | Customer | OrderDate | SalesAmount | Region |
|---|---|---|---|---|
| 1001 | Alpha Co | 2024-01-15 | 250 | North |
| 1002 | Beta LLC | 2024-01-20 | 400 | East |
| 1003 | Gamma Inc | 2024-02-05 | 150 | South |
| 1004 | Alpha Co | 2024-02-10 | 300 | North |
| 1005 | Delta Ltd | 2024-02-15 | 500 | West |
Total Sales = SUM(Sales[SalesAmount])
+----------------------+----------------------+ | Total Sales | Sales by Region | | (KPI Card) | (Bar Chart) | +----------------------+----------------------+ | Recent Orders | | (Table) | +----------------------------------------------+
A slicer filters data by Region. Selecting a region updates the Total Sales KPI, the Sales by Region bar chart (highlighting the selected region), and the Recent Orders table to show only orders from that region.
Data refreshes automatically from the OData and REST API sources when the dashboard is opened or refreshed, ensuring live data.
Add a filter for Region = North. Which components update and what changes occur?
OData connection in Power BI compared to a generic REST API?Web.Contents() function fetches data from any web URL, including REST APIs.OData.Feed() is specific for OData sources, not generic REST APIs.let
Source = OData.Feed("https://services.odata.org/V4/Northwind/Northwind.svc/Products"),
Filtered = Table.SelectRows(Source, each [CategoryID] = 1)
in
FilteredOData.Feed() function returns a table of products from the OData service.Table.SelectRows() filters rows where CategoryID equals 1, which is valid for this dataset.let
Source = Web.Contents("https://api.example.com/data"),
Json = Json.Document(Source),
Table = Table.FromList(Json, Splitter.SplitByNothing())
in
TableTable.FromList() expects a list, but if JSON is an object (record), it cannot convert directly.OData.Feed() for the OData product details and Web.Contents() with Json.Document() to parse REST API stock JSON.Pass the test and this pattern moves unknown