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
Sullyvall2
New Member

Get data ready for Venn diagram from customer logins by channel

I want to use the Venn diagram by MAQ LLC visual to show the numbers of customers that log in during a time window (Google analytics data source). I have two channels: "mobile" and "desktop". The Venn will show the count of customers that logged in mobile only, desktop only and the intersection both mobile and desktop. Values should update as I move my date slider filter. My log in data is in this format:

raw_data.png

 

A summary of this information can be seen in the Pivot table:

pivot.png

The Venn diagram by MAQ LLC requires the data to be in this format...

req output.png...where 1 represents use of that chaannel type

I've tried various combinations of CALCULATETABLE(), SUMMARIZE() AND ADDCOLUMNS() and INT() but to no avail. Any assistance welcome.

 

Many thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Sullyvall2 ,

I created a sample pbix file(see the attachment), please check if that is what you want.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUcrNT8rJTAUyDA30jSz0jQyMjJVidSByKanF2SX5BRRLWqJKIltpbICQc8JnKqYkkqnOeEzFkDNEyLngM9QFj6Gu+DS64tHohifI3fHIeeCSiwUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [user_id = _t, device_category = _t, date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"user_id", type text}, {"device_category", type text}, {"date", type date}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[device_category]), "device_category", "user_id", List.Count),
    #"Added Custom" = Table.AddColumn(#"Pivoted Column", "Count", each [moblie]+[desktop]),
    #"Replaced Value" = Table.ReplaceValue(#"Added Custom",each [moblie],each if [moblie] > 0 then 1 else [moblie] ,Replacer.ReplaceValue,{"moblie"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",each [desktop],each if [desktop] > 0 then 1 else [desktop] ,Replacer.ReplaceValue,{"desktop"})
in
    #"Replaced Value1"

vyiruanmsft_0-1700041062761.png

Best Regards

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Sullyvall2 ,

I created a sample pbix file(see the attachment), please check if that is what you want.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUcrNT8rJTAUyDA30jSz0jQyMjJVidSByKanF2SX5BRRLWqJKIltpbICQc8JnKqYkkqnOeEzFkDNEyLngM9QFj6Gu+DS64tHohifI3fHIeeCSiwUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [user_id = _t, device_category = _t, date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"user_id", type text}, {"device_category", type text}, {"date", type date}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[device_category]), "device_category", "user_id", List.Count),
    #"Added Custom" = Table.AddColumn(#"Pivoted Column", "Count", each [moblie]+[desktop]),
    #"Replaced Value" = Table.ReplaceValue(#"Added Custom",each [moblie],each if [moblie] > 0 then 1 else [moblie] ,Replacer.ReplaceValue,{"moblie"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",each [desktop],each if [desktop] > 0 then 1 else [desktop] ,Replacer.ReplaceValue,{"desktop"})
in
    #"Replaced Value1"

vyiruanmsft_0-1700041062761.png

Best Regards

Thanks. I couldn't see the wood for the trees. It never dawned on me to do it in Power Query. I was focused on getting it in DAX. I had another case where the data was already pivoted so could use this dax to get the data in the shape needed for the Venn.

MPF_Venn = CALCULATETABLE(

                ADDCOLUMNS(

 

                    SELECTCOLUMNS('MyTable'

                    ,"event_date",'MyTable' [event_date]

                    , "sub_product", 'MyTable' [question_1]

                    , "question_2", 'MyTable' [question_2]

                    )

                ,"Product B", SWITCH([question_2],"Yes",1,0)

                ,"Product A1", SWITCH([question_1],"Just A1",1,"I need both",1,0)

                ,"Product A2", SWITCH([question_1],"Just A2",1,"I need both",1,0)

                )

            , 'MyTableWithOtherData' [form_product]="Products A or B"

            )

 

Thanks for the Power Query solution...much appreciated

Sullyvall2
New Member

Data as a table for assistance

user_iddevice_categorydate
Amoblie28/10/2023
Adesktop28/10/2023
Adesktop28/10/2023
Adesktop29/10/2023
Amoblie30/10/2023
Bdesktop28/10/2023
Bdesktop29/10/2023
Cmoblie30/10/2023
Cmoblie31/10/2023
Ddesktop29/10/2023
Dmoblie30/10/2023
Edesktop29/10/2023
Emoblie30/10/2023
Fmoblie28/10/2023
Gmoblie28/10/2023
Hmoblie28/10/2023

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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.