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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Add Google Analytics Custom Segment

Hi, 

 

I am trying to get some Google Analytics data into PowerBI, however I need to filter it for a specific segment. I was searching the web for an answer, but could not find anything relevant. 

 

In essence, I need to filter everything for this: sessions::condition::ga:orderCode==XX11XX2X [or gaid:xxxxxxxxxxxxxxxxx] (taken from G.A. query explorer)

 

Query below if it helps:

 

let Multiple =(id1 as text,id2 as text,id3 as text)=>
let
Source = GoogleAnalytics.Accounts(),
#"11111111" = Source{[Id=id1]}[Data],
#"XX-11111111-1" = #"11111111"{[Id=id2]}[Data],
#"11111111" = #"XX-11111111-1"{[Id=id3]}[Data],
#"Added Items" = Cube.Transform(#"11111111",
{
{Cube.AddAndExpandDimensionColumn, "ga:yearMonth", {"ga:yearMonth"}, {"yyyymm"}},
{Cube.AddMeasureColumn, "Sessions", "ga:sessions"},
{Cube.AddMeasureColumn, "Bounces", "ga:bounces"},
{Cube.AddMeasureColumn, "Transactions", "ga:transactions"},
{Cube.AddMeasureColumn, "BounceRate", "ga:bounceRate"}
}),
#"Filtered Rows" = Table.SelectRows(#"Added Items", each [yyyymm] >= 201701)

in
#"Added Items"
in Multiple

 

Any help will be appreciated.

 

Thx ! 

1 REPLY 1
v-yuta-msft
Community Support
Community Support

Hi sailor321,

 

Both GA connector and Web.Contents() don't support custom segment in power query currently because post request in Web.Contents() function doesn't support OAuth2. In addtion, it's still a requested feature, please refer to this idea. As a workaround, you may use python or R script to achieve the filtered data from GA and then import the data into power bi.

 

Regards,

Jimmy Tao

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.