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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
benekun
Frequent Visitor

Visualize Mulitselection Survey Questions with a Relative Bar Chart

Hello everyone,

 

I have created a dashboard to visualize complex survey data. This video has helped a lot and shows the kind of question I am dealing with: https://www.youtube.com/watch?v=rI0uHdBwgPY. Essentially, the survey was conducted in two years (20222 and 2023). Each row refers to a person who has answered the survey and has a weight smaller than 1 if this group is overrepresented in the survey and bigger than 1 if it is underrepresented. My problem lies with the multiselection question (last two columns). The raw data has the structure as shown below (short example):

post_1.png

To achieve the data structure shown in the video, I replace the "No" values with "null" and the "Yes" values with either "MS Word" or "Facebook". I than create a new querry with the ID and the last two columns, unpivot the multiselection columns and remove the attribute column:

post_2.png

I then created a bar chart using "App" column from the querry above as y-axis, the survey year from the original querry as the legend, and the sum of weights from the original querry. This results in the following chart with an example slicer for the gender:

post_3.png

This result comes very close to my desired chart. The only problem that I have is that I want relative values, i. e. 59% of the people taking the survey in 2022 use MS Word and 74% use Facebook (in this example the sum of weights coincides with the percentage values because I chose a sample size of 10 per year). Showing the weights as a percentage of the total does not achieve my desired outcome as I don't want percentages of th total sum.

post_4.png

 

I hope that I could make my problem clear. I am happy to provide you with any further information. 

 

Thank you so much in advance for your time and help.

2 ACCEPTED SOLUTIONS
v-yifanw-msft
Community Support
Community Support

Hi @benekun ,

Depending on the information you have provided, you can follow these steps below:

1.Add new columns.

MS Word = 
VAR _YEAR = 'Table'[Year]
VAR _MSWord =
    CALCULATE (
        COUNT ( 'Table'[App] ),
        FILTER ( 'Table', 'Table'[Year] = _YEAR && 'Table'[App] = "MS Word" )
    )
VAR _ALL =
    CALCULATE ( COUNT ( 'Table'[App] ), FILTER ( 'Table', 'Table'[Year] = _YEAR ) )
RETURN
    _MSWord / _ALL
Facebook = 
VAR _YEAR = 'Table'[Year]
VAR _Facebook =
    CALCULATE (
        COUNT ( 'Table'[App] ),
        FILTER ( 'Table', 'Table'[Year] = _YEAR && 'Table'[App] = "Facebook" )
    )
VAR _ALL =
    CALCULATE ( COUNT ( 'Table'[App] ), FILTER ( 'Table', 'Table'[Year] = _YEAR ) )
RETURN
    _Facebook / _ALL

2.Add new measures.

MS = 
VAR _YEAR =
    SELECTEDVALUE ( 'Table'[Year] )
RETURN
    CALCULATE (
        MAX ( 'Table'[MS Word] ),
        FILTER ( 'Table', 'Table'[Year] = _YEAR )
    )
FB = 
VAR _YEAR =
    SELECTEDVALUE ( 'Table'[Year] )
RETURN
    CALCULATE (
        MAX ( 'Table'[Facebook] ),
        FILTER ( 'Table', 'Table'[Year] = _YEAR )
    )

3.Put measures in visual.

vyifanwmsft_0-1712801686015.png

Final output:

vyifanwmsft_1-1712801714224.png

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

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

Update: I could solve the problem using the quite new visual calculations.

View solution in original post

3 REPLIES 3
benekun
Frequent Visitor

Hi Ada,

 

first of all, I want to thank you for your very detailled response. That brings me closer to my desired solution. 

 

To make it easier, I put the sample data as well as the desired diagramm including calculations in this google sheet: https://docs.google.com/spreadsheets/d/1C5q65OKPGnXgYdTMAudUhqZLo2Odk2K60kAiXqNMOA8/edit?usp=sharing

 

Ideally, the diagramm would look like this (grouped by application):

chart.png

 

 

 

 

 

 

 

 

 

 

 

Another issue that I am facing is that I cannot simply count the respective rows and calculate the percentages accordingly. Since this is weighted data, I have to sum the weights according to the answer options for each year and divide it by the non-NA sum per year. Using excel for 2022: =SUMIFS(Data!$E:$E;Data!$B:$B;2022;Data!$F:$F;"Yes")/SUMIFS(Data!$E:$E;Data!$B:$B;2022;Data!$F:$F;"<>NA")

 

I hope that clarified things. Unfortunately, I was not able to adapt your Power BI suggestions accordingly. I hope the excel example is sufficient.

 

Thank you again for your time.

 

Best regards,
Benedikt Franz

Update: I could solve the problem using the quite new visual calculations.

v-yifanw-msft
Community Support
Community Support

Hi @benekun ,

Depending on the information you have provided, you can follow these steps below:

1.Add new columns.

MS Word = 
VAR _YEAR = 'Table'[Year]
VAR _MSWord =
    CALCULATE (
        COUNT ( 'Table'[App] ),
        FILTER ( 'Table', 'Table'[Year] = _YEAR && 'Table'[App] = "MS Word" )
    )
VAR _ALL =
    CALCULATE ( COUNT ( 'Table'[App] ), FILTER ( 'Table', 'Table'[Year] = _YEAR ) )
RETURN
    _MSWord / _ALL
Facebook = 
VAR _YEAR = 'Table'[Year]
VAR _Facebook =
    CALCULATE (
        COUNT ( 'Table'[App] ),
        FILTER ( 'Table', 'Table'[Year] = _YEAR && 'Table'[App] = "Facebook" )
    )
VAR _ALL =
    CALCULATE ( COUNT ( 'Table'[App] ), FILTER ( 'Table', 'Table'[Year] = _YEAR ) )
RETURN
    _Facebook / _ALL

2.Add new measures.

MS = 
VAR _YEAR =
    SELECTEDVALUE ( 'Table'[Year] )
RETURN
    CALCULATE (
        MAX ( 'Table'[MS Word] ),
        FILTER ( 'Table', 'Table'[Year] = _YEAR )
    )
FB = 
VAR _YEAR =
    SELECTEDVALUE ( 'Table'[Year] )
RETURN
    CALCULATE (
        MAX ( 'Table'[Facebook] ),
        FILTER ( 'Table', 'Table'[Year] = _YEAR )
    )

3.Put measures in visual.

vyifanwmsft_0-1712801686015.png

Final output:

vyifanwmsft_1-1712801714224.png

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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