Bird
Raised Fist0
Power BIbi_tool~15 mins

OData and REST API connections in Power BI - Real Business Scenario

Choose your learning style10 modes available
Scenario Mode
👤 Your Role: You are a business intelligence analyst at a retail company.
📋 Request: Your manager wants you to create a report that shows the latest product sales data by connecting Power BI directly to the company's online sales system using OData and REST API connections.
📊 Data: You have access to the company's OData feed URL that provides product sales data including ProductID, ProductName, SalesDate, QuantitySold, and SalesAmount. Additionally, you have a REST API endpoint that returns customer feedback data with CustomerID, ProductID, FeedbackDate, and Rating.
🎯 Deliverable: Create a Power BI report that combines sales data from the OData feed and customer feedback from the REST API. The report should show total sales and average customer rating per product.
Progress0 / 6 steps
Sample Data
ProductIDProductNameSalesDateQuantitySoldSalesAmount
101Wireless Mouse2024-05-0115300
102USB Keyboard2024-05-0110250
101Wireless Mouse2024-05-0220400
103Webcam HD2024-05-025150
102USB Keyboard2024-05-038200
103Webcam HD2024-05-037210

CustomerIDProductIDFeedbackDateRating
C0011012024-05-024
C0021022024-05-025
C0031012024-05-033
C0041032024-05-034
C0051022024-05-044
1
Step 1: Connect Power BI to the OData feed URL to import product sales data.
In Power BI Desktop, go to 'Get Data' > 'OData Feed', enter the OData URL, and load the ProductSales table.
Expected Result
Product sales data with columns ProductID, ProductName, SalesDate, QuantitySold, SalesAmount is loaded into Power BI.
2
Step 2: Connect Power BI to the REST API endpoint to import customer feedback data.
In Power BI Desktop, go to 'Get Data' > 'Web', enter the REST API URL, use 'Advanced' to set HTTP method to GET, and parse the JSON response to extract CustomerFeedback table with CustomerID, ProductID, FeedbackDate, Rating.
Expected Result
Customer feedback data is loaded into Power BI with columns CustomerID, ProductID, FeedbackDate, Rating.
3
Step 3: Create a relationship between ProductSales and CustomerFeedback tables on ProductID.
In Power BI Model view, drag ProductID from ProductSales to ProductID in CustomerFeedback to create a one-to-many relationship.
Expected Result
Tables are linked by ProductID allowing combined analysis.
4
Step 4: Create a measure to calculate total sales amount per product.
Total Sales = SUM(ProductSales[SalesAmount])
Expected Result
Measure 'Total Sales' sums sales amount for each product.
5
Step 5: Create a measure to calculate average customer rating per product.
Average Rating = AVERAGE(CustomerFeedback[Rating])
Expected Result
Measure 'Average Rating' calculates average rating for each product.
6
Step 6: Build a report visual showing ProductName, Total Sales, and Average Rating.
Add a table visual with fields: ProductName, Total Sales, Average Rating.
Expected Result
Report table displays each product with its total sales and average customer rating.
Final Result
---------------------------------------------
| Product Name   | Total Sales | Avg Rating |
---------------------------------------------
| Wireless Mouse | $700        | 3.5        |
| USB Keyboard   | $450        | 4.5        |
| Webcam HD      | $360        | 4.0        |
---------------------------------------------
✓Wireless Mouse has the highest total sales but a moderate average rating of 3.5.
✓USB Keyboard has lower sales but the highest average customer rating of 4.5.
✓Webcam HD has the lowest sales and a good average rating of 4.0.
Bonus Challenge

Add a time filter slicer to the report to allow filtering sales and feedback data by SalesDate and FeedbackDate.

Show Hint
Create a date table and relate it to both ProductSales[SalesDate] and CustomerFeedback[FeedbackDate]. Use slicers linked to the date table.

Practice

(1/5)
1. What is the main advantage of using an OData connection in Power BI compared to a generic REST API?
easy
A. It cannot refresh data automatically.
B. It requires manual coding for every data request.
C. It only works with Excel files.
D. It provides a standardized query language and easier data filtering.

Solution

  1. Step 1: Understand OData protocol features

    OData supports standardized query options like filtering, sorting, and paging directly in the URL.
  2. Step 2: Compare with REST API flexibility

    REST APIs are flexible but often require custom query parameters and manual handling of data requests.
  3. Final Answer:

    It provides a standardized query language and easier data filtering. -> Option D
  4. Quick Check:

    OData = Standardized queries [OK]
Hint: OData uses standard queries; REST APIs need custom calls [OK]
Common Mistakes:
  • Thinking OData only works with Excel
  • Assuming REST APIs auto-refresh data
  • Believing OData requires manual coding
2. Which Power Query M function is used to connect to a REST API endpoint in Power BI?
easy
A. OData.Feed()
B. Web.Contents()
C. Csv.Document()
D. Excel.Workbook()

Solution

  1. Step 1: Identify function for REST API calls

    The Web.Contents() function fetches data from any web URL, including REST APIs.
  2. Step 2: Differentiate from OData function

    OData.Feed() is specific for OData sources, not generic REST APIs.
  3. Final Answer:

    Web.Contents() -> Option B
  4. Quick Check:

    REST API = Web.Contents() [OK]
Hint: Use Web.Contents() for REST API URLs [OK]
Common Mistakes:
  • Using OData.Feed() for REST APIs
  • Confusing CSV import with API calls
  • Trying Excel.Workbook() for web data
3. Given this Power Query M code snippet connecting to an OData feed:
let
  Source = OData.Feed("https://services.odata.org/V4/Northwind/Northwind.svc/Products"),
  Filtered = Table.SelectRows(Source, each [CategoryID] = 1)
in
  Filtered

What will be the result?
medium
A. An empty table because CategoryID is not a valid column.
B. An error because OData.Feed cannot filter data.
C. A table of products where CategoryID equals 1.
D. A list of all categories instead of products.

Solution

  1. Step 1: Understand OData.Feed output

    The OData.Feed() function returns a table of products from the OData service.
  2. Step 2: Analyze filtering step

    Table.SelectRows() filters rows where CategoryID equals 1, which is valid for this dataset.
  3. Final Answer:

    A table of products where CategoryID equals 1. -> Option C
  4. Quick Check:

    Filter by CategoryID=1 = filtered product table [OK]
Hint: OData.Feed returns tables; filter with Table.SelectRows() [OK]
Common Mistakes:
  • Assuming OData.Feed cannot filter
  • Confusing products with categories
  • Thinking CategoryID column is missing
4. You wrote this Power Query M code to get data from a REST API:
let
  Source = Web.Contents("https://api.example.com/data"),
  Json = Json.Document(Source),
  Table = Table.FromList(Json, Splitter.SplitByNothing())
in
  Table

But you get an error saying "Expression.Error: We cannot convert the value to a table." What is the likely cause?
medium
A. The JSON returned is an object, not a list, so Table.FromList fails.
B. Web.Contents() cannot fetch JSON data.
C. Json.Document() only works with XML data.
D. Splitter.SplitByNothing() is not a valid function.

Solution

  1. Step 1: Check JSON structure expected

    Table.FromList() expects a list, but if JSON is an object (record), it cannot convert directly.
  2. Step 2: Understand error cause

    The error means the JSON is not a list but an object, so conversion fails.
  3. Final Answer:

    The JSON returned is an object, not a list, so Table.FromList fails. -> Option A
  4. Quick Check:

    JSON object ≠ list causes conversion error [OK]
Hint: Check if JSON is list or object before Table.FromList() [OK]
Common Mistakes:
  • Thinking Web.Contents() can't get JSON
  • Assuming Json.Document() only parses XML
  • Believing Splitter.SplitByNothing() is invalid
5. You want to combine data from an OData feed and a REST API in Power BI. The OData feed provides product details, and the REST API returns live stock levels as JSON. Which approach is best to create a unified table for reporting?
hard
A. Use OData.Feed() to get products, Web.Contents() + Json.Document() for stock, then merge tables in Power Query.
B. Use only OData.Feed() for both sources since it supports all APIs.
C. Import REST API JSON as CSV and append to OData feed table directly.
D. Load both sources separately and create relationships in the data model without merging.

Solution

  1. Step 1: Connect to each data source appropriately

    Use OData.Feed() for the OData product details and Web.Contents() with Json.Document() to parse REST API stock JSON.
  2. Step 2: Combine data in Power Query

    Merge the two tables on product ID to create a unified table before loading into the report.
  3. Final Answer:

    Use OData.Feed() to get products, Web.Contents() + Json.Document() for stock, then merge tables in Power Query. -> Option A
  4. Quick Check:

    Combine sources with correct connectors and merge [OK]
Hint: Use correct connectors per source, then merge in Power Query [OK]
Common Mistakes:
  • Trying to use OData.Feed() for REST API JSON
  • Appending JSON as CSV without parsing
  • Not merging data, just relating tables
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard