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
Anonymous
Not applicable

Dynamically Generating Tables from AdobeAnalytics API within Power BI Desktop - Power Query (M)

Hello Power Query (M) and Power BI Gurus!

 

I'm trying to use 3 Lists within Power BI Desktop as my Parameters to create tables using the AdobeAnalytics Connector (API) (See Below for the generated Power Query Code). The AdobeAnalytics Connector only allows for the use of Segments stacked on top of each other (For those that are not familiar with AdobeAnalytics think of a segment as a filter). So my only option (that I see thus far) is to iterate through all possible combinations of the 3 lists to generate all of the calls (i.e. trying to a Nested Loop that creates all of these tables for me and then combines them to one table).

Data Components:

  • 3 Lists of values to use as my Nested Parameters for each call

    • Programs (1 Column)

      • A
      • B
      • C
    • Regions (1 Column)

      • A1
      • B2
      • C3
    • MarketingChannels (1 Column)

      • A11
      • B22
      • C33
  • Power BI Desktop - Power Query AdobeAnalytics API connection

Required Steps

1. Create a table for every combination of the Values within the 3 Lists e.g.:

  • Table 1 would use the following parameters:
    • (#Programs[A], #Regions[A1], #MarketingChannels[A11])
  • Table 2 would use the following parameters:
    • (#Programs[A], #Regions[A1], #MarketingChannels[B22])
  • Continue until all possible combinations are completed

2. Once all of the tables have been created I need to combine them

 

The below code snippet would be an example of Table 1,

(note the line that starts with "{Cube.ApplyParameter, "Segment","as that is where the Lists above would be used as parameters)

 

let
    Source = AdobeAnalytics.Cubes(),
    invitrogenprod = Source{[Id="invitrogenprod"]}[Data],
    #"Added Items" = Cube.Transform(invitrogenprod,
        {
            {Cube.ApplyParameter, "DateRange", {#date(2018, 3, 21), #date(2018, 3, 21)}},

            {Cube.ApplyParameter, "Segment", {{"#Programs[A]", "#Regions[A1]", "#MarketingChannels[A11]"}}},

            {Cube.AddAndExpandDimensionColumn, "DateGranularity", {"year", "month", "day"}, {"Date Granularity.Level 1: Year", "Date Granularity.Level 2: Month", "Date Granularity.Level 3: Day"}},
            {Cube.AddMeasureColumn, "Engaged Visits", "cm300001617_5a84e003de3c977de97c39d2"},
            {Cube.AddMeasureColumn, "Engaged Visits (PDP)", "cm300001617_5a58160e8f0c657d68a6e404"},
            {Cube.AddMeasureColumn, "Visits w/ Cart Activity", "cm300001617_5a50160c4ecbca5712928ab6"}
        })
in
    #"Added Items"

 

 

Any and all help will be greatly appreciated!!!

1 ACCEPTED SOLUTION

@Anonymous,

How about creating a single parameter that listing all the possible combination values, then using this single paramater in your M script?

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-yuezhe-msft
Employee
Employee

@Anonymous,

A method I can think of is to create parameters(e.g, program parameter,regions parameter and marketing parameter) that contained the following values in Power BI Desktop, then use these parameters into your Power Query code.


(#Programs[A], #Regions[A1], #MarketingChannels[A11])

(#Programs[A], #Regions[A1], #MarketingChannels[B22])

There is a blog for your reference:
http://biinsight.com/power-bi-desktop-query-parameters-part-1/

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you for the response Lydia! I was already aware of and am using parameters but I need to not just print the parameters but run the same query for all possible combinations of those parameters in the query I listed in the original post (I have already added in parameters to where they would need to be placed).

@Anonymous,

Do you list all possible values when creating parameters? If you have, you are able to choose values from drop-down list.
1.PNG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you again for your response! I need to run this for every possible combination of the list of values. So need less to say that would be a bit time consuming if I were to have to choose the combination Everytime.

@Anonymous,

How about creating a single parameter that listing all the possible combination values, then using this single paramater in your M script?

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

Top Solution Authors
Top Kudoed Authors