How to filter dimension values when fetching data from Google Analytics into PowerQuery/PowerBi

behnam_ab

New Member
Joined
Apr 3, 2016
Messages
2
I want to fetch data from Google Analytics With M (PowerQuery/PowerBI), but want to filter the dimension values on the fily, Let's Say my dimension is "Page" and I want "Pageviews" and "Unique Pageviews" measures, provided that the "Page" is following a regex filter (ex. <code>ga:pagePath=~^.*?([0-9]{6,7}|mpg[0-9]{1,3}){1}\.html[/]?[^ ]*</code>)
I could use "<code>Table.SelectRows</code>", but as M doesn't support regex, this filter should be passed to GA api directly. Here is what M generated for me:
Code:
<code>    let
    Source = GoogleAnalytics.Accounts(),
    #"1234567" = Source{[Id="1234567"]}[Data],
    #"UA-987654-1" = #"1234567"{[Id="UA-52004541-1"]}[Data],
    #"11111" = #"UA-987654-1"{[Id="1234567"]}[Data],
    #"Added Items" = Cube.Transform(#"11111", {{Cube.AddAndExpandDimensionColumn, "ga:pagePath", {"ga:pagePath"}, {"Page"}}, {Cube.AddMeasureColumn, "Pageviews", "ga:pageviews"}, {Cube.AddMeasureColumn, "Unique Pageviews", "ga:uniquePageviews"}}),
    #"Filtered Rows" = Table.SelectRows(#"Added Items", each Text.Contains([Page], "html"))
in
    #"Filtered Rows"
</code>
Is there any possiblity to pass my regex filter to GA api in M?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,213,527
Messages
6,114,148
Members
448,552
Latest member
WORKINGWITHNOLEADER

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top