Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
5AMsan
Frequent Visitor

Manage function (or table) parameters in Navigation Table

Hello,

I'm trying to add parameters to API calls. OAuth is working and I can generate a list of available datasets in a dynamic navigation table:

5AMsan_0-1661956263330.png

 

Here is the auth screen with no optional parameters, the one I want to appear in the screenshot above (in the right pane):

5AMsan_1-1661956819244.png

 

Now I can't figure out how to allow date and dimension parameters and show on right pane (the one showing error, since dates and dimensions are null).

 

I read the whole TripPin walkthrough several times to end up at this point, but I'm getting lost about parameters and navigation table...

 

Here is some relevant code:

 

 

[DataSource.Kind="PQ_SearchConsole", Publish="PQ_SearchConsole.Publish"]
shared PQ_SearchConsole.Contents = Value.ReplaceType(CreateNavTable, contentsType);
contentsType = type function (
    optional start as (type text meta [
        Documentation.FieldCaption = "Début",
        Documentation.FieldDescription = "Date de début de l'extraction (les mots clés sont autorisés : `today`, `yesterday`, `60daysAgo`).",
        Documentation.SampleValues = {"2022-01-01"}
    ]),
    optional end as (type text meta [
        Documentation.FieldCaption = "Fin",
        Documentation.FieldDescription = "Date de fin de l'extraction (les mots clés sont autorisés : `today`, `yesterday`, `60daysAgo`).",
        Documentation.SampleValues = {"yesterday"}
    ]),
    optional params  as (type nullable text meta [
        Documentation.FieldCaption = "Dimensions",
        Documentation.FieldDescription = "Saisir les dimensions souhaitées",
        Documentation.SampleValues = {"query,page,device,country"}
    ])

) as table [...]
CreateNavTable = (
    optional start as text, 
    optional end as text, 
    optional params as nullable text
) as table => 
    let
        sites = GetSitesList(),
        navBody = List.Accumulate( sites[siteUrl], {}, (state, current)=> state &
            {{current, current, PQ_SearchConsole.GetContents(current,start,end,params), "Function", "Function", true}}
        ),

        navHeader = {"Name","Key","Data","ItemKind", "ItemName", "IsLeaf"}, 
        objects = #table(navHeader, navBody),
        NavTable = Table.ToNavigationTable(objects, {"Key"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf")
    in
        NavTable
GetSitesList = () as table => 
    let
        source = Json.Document( Web.Contents ( api_base_uri ) ),
        sites = Table.FromRecords( source[siteEntry], type table[siteUrl = Text.Type /*, permissionLevel = Text.Type*/] )
    in
        sites;
PQ_SearchConsole.GetContents = (
    website as text,
    start as text, 
    end as text, 
    params as nullable text
)  =>
    let 
        now =  DateTime.FixedLocalNow(), 

        reqStartDate = Date.From(dateFunc(start)), // #date( Date.Year(now), Date.Month(now) - 1 , Date.Day(now) ),
        reqEndDate = Date.From(dateFunc(end)), //  #date( Date.Year(now), Date.Month(now), Date.Day(now) ),
        reqDimensions = if params="" or params = null then {} else Text.Split(params,","),
        source = Web.Contents( api_base_uri, [
            RelativePath = Text.Combine({Uri.EscapeDataString(website), "/searchAnalytics/query"}), 
            Headers = [#"Content-Type"="application/json"],
            Content = Json.FromValue([startDate = reqStartDate, endDate = reqEndDate, dimension = reqDimensions]) 
        ]),
        report = Json.Document(source)
    in
        report

 

 

 

3 REPLIES 3
5AMsan
Frequent Visitor

I must admit I'm quite puzzled there's no documentation about having parameters for functions or tables exposed as navigation in Power BI. I'm sure some connectors use this, but no way to find anything about this 😕

v-chenwuz-msft
Community Support
Community Support

Hi @5AMsan ,

 

Did you get your problem solved?

Hello @v-chenwuz-msft 

 

Not at all ^^ 
I enjoyed a long week-end and then now I can dive in again!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.