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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
SHADOWFAX
New Member

Count of times Y is selected FOR EACH client id

Have some survey data that I need help figuring out for each unique respondent, the number of respondents that select Y once, selected Y twice, selcted Y 3 times and so on. My data is setup as follow.

SHADOWFAX_0-1671730620072.png

So in the above example, there would be a total of 2 unique respodents that answered Y to 3 questions, 1 unique respodent that answered Y to 2 questions, and 2 unique respodents that selected Y to 1 question.

 

Need to be able to graph the results in a bar chat by the frequency of Y answers for each unqiue client id.

Below is the same data setup in a color scheme by Client ID to easier viewing.

SHADOWFAX_1-1671730934997.png

 

Thanks in advance

 

7 REPLIES 7
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
sturlaws
Resident Rockstar
Resident Rockstar

Hi, , 

first create a frequency table like this:

Frequencies = GENERATESERIES(0,10,1)

 and rename the column [Value] to [Frequency]. This table should have no relationship to any other table.

 
Next create this measure:
Frequency Y answers = VAR _frequency = SELECTEDVALUE ( Frequencies[Frequency] ) VAR _CountOfYesPerClient = ADDCOLUMNS ( VALUES ( Survey[Client ID] ), "count", CALCULATE ( COUNTROWS ( Survey ), Survey[Answer] = "Y" ) ) VAR _frequencyCount = COUNTROWS ( FILTER ( _CountOfYesPerClient, [count] = _frequency ) ) RETURN _frequencyCount You should now be able to create this chart: 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

 

sturlaws_2-1671754626008.png

Getting the following error when trying to create the second measure VAR_CountOfYesPerClient

"The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value"

SHADOWFAX_1-1671761380692.png

 

Here is the full measure with the error

SHADOWFAX_0-1671761328468.png

 

Thanks for your help!

It seems like you are pulling in two different tables in your measure, I have no way of knowing how they are related.

It would be helpful if you could share your pbix, or if that is not possible, create an example file reproducing your model.

 

Hi @SHADOWFAX ,

 

Please try like:

 

CountOfYesPerClient =
ADDCOLUMNS (
    VALUES ( 'SDOH Survey Data'[ID] ),
    "count", CALCULATE ( COUNTROWS ( 'SDOH Survey Data' ), 'SDOH Survey Data'[Answer] = "Y" )
)

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

sorry about the formatting, the forum is acting up all weird

Ahmedx
Super User
Super User

look it up you need it
https://dropmefiles.com/fSd7Y

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.