Skip to main content
Question

Power BI: Use parameter to specify CDF tenant when querying Sequences with Cognite Extractor

  • September 9, 2024
  • 5 replies
  • 34 views

Anders Brakestad
Seasoned

Hi guys!

 

We are developing a Power BI dashboard that relies on time series and sequences fetched from CDF using the Cognite Extractor. We have set up a deployment pipeline for our dashboards (Dev, Test, and Prod), where each environment in the PBI pipeline corresponds to data sources in the respective CDF tenant. I.e., our Dev dashboard reads data from our dev tenant in CDF, and so on.

 

We get this to work by configuring a Parameter in Power BI desktop with values that match our CDF tenants.Then we refer to these parameters when we define the data sources. Here is an example of how we use push-down filtering via OData queries from the Advanced Editor in Power Query:

Source = Cognite.Contents(cdf_env & "/Timeseries/?$filter=ExternalId eq 'our_special_external_id'", null),

The variable “cdf_env” evaluates by default to Dev, and we have configured the deployment pipeline such that this parameter updates automatically when we deploy from Dev to Test, and from Test to Prod.

 

But here is the problem. This only works in our Time Series queries. When we try to use the same logic in our Data Sources that point to CDF sequences we get errors. This means we have had to resort to hard-coding the CDF tenant in our data source connection in  Dev, and currently cannot deploy to Test and get the automatic CDF tenant correct. It will require a bunch of manual downloading of semantic models, updating the hard-coded env, and republishing to Test. This workflow will not work well.

 

So, is there something with the Cognite Connector that leads to this limitation? 

 

I appreciate all help and advice! :) 

5 replies

Everton Colling
Seasoned Practitioner
Forum|alt.badge.img
  • Seasoned Practitioner
  • 163 replies
  • September 9, 2024

Hi Anders,

To better help you out, we would need more information on this. Could you please provide:

  • The exact error messages you're seeing when trying to use the parameterized approach with Sequences
  • A sample of the query you're using for Sequences (similar to the Time Series example you provided)

Power BI often provides limited error information. Optionally, to get a better understanding of what's happening, we recommend using a tool like Fiddler to monitor the requests being sent from Power BI to CDF. This will allow us to see:

  • The exact URL and query parameters being sent to the OData service
  • The response returned by CDF

This information can help us identify whether the issue is with parameter substitution, query formation, or something else.


Anders Brakestad
Seasoned

Thanks for the feedback! I will try to gather more debug information about this and update the thread.


Anders Brakestad
Seasoned

Hi @Everton Colling 

Sorry for the late follow-up.

I have downloaded FiddlerCap (the only free option I think), but I am not sure how to use it to collect the information you need. Could you explain a bit more how I can collect what you need?

Thanks!

Anders


Everton Colling
Seasoned Practitioner
Forum|alt.badge.img
  • Seasoned Practitioner
  • 163 replies
  • October 28, 2024

Hi @Anders Brakestad,

The tool we use is Fiddler Classic (https://www.telerik.com/fiddler/fiddler-classic). After installing it, you need to open it before opening Power BI, and then you should be able to track requests sent from your Power BI desktop application (see screenshot below):

What would be relevant to troubleshoot is the request URL (GET /odata/v1/…. in the image below) and the response body (JSON @odata…. in the image below) associated to failed requests (status different than 200).

 


Anders Brakestad
Seasoned

@Everton Colling 

 

Hi again. 

I have finally done some more testing on this subject:

  • I made a blank report in Power BI Desktop
  • Added two time series source and two sequence source
  • One set uses the parameter, while the other set use hard-coded environments
  • I load their data and make some simple visualizations

I save and close. Then open Fiddler and after open the report.

When I push the “Refresh” button, which triggers the data retrieval from all data sources, I get the following.

 

All data sources get data, and so it seems to work.

 

However, If I set up a new blank query, write the data source request using the parameter like so:

 

let
    Source = Cognite.Contents(cdf_env_gcp & "/Sequences?$filter=Name eq 'Sequence - Alarm KPIs - Valhall - Top 10 Alarms'", null)
in
    Source

I.e., I don’t do any unpacking of the row data, then I don’t get any preview in Query Editor. I don’t have the option to actually unpack the row data. If I load the Source into the model I just get the “top level” data columns, and no row data or metadata. 

 

So to get this to work I need to first connect to the data source WITHOUT a paramter, unpack and transform the way I need, and then update the request by replacing the CDF environment with the parameter. Then when I load the data I get all row data as expected.

 

So it looks like it works, kind of. I still need to test that the parameter actually updates correctly in a PBI Service Deployment Pipeline. I will report back here after the tests.

PS. I tested all of this both on AZ and GCP CDF tenants, and get the same results for both.


Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings