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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Dpit
New Member

dax calculation

 

Hello


I'm contacting you because I can't get a DAX formula related to my needs
these my issue :

I have, in my datasource 3 columns
my table aims to analyze answers to survey questions

I have, in my source, 4 main columns


ID_PERSON (person who responded)
QUESTION_ID (
ANSWER (answer to the question)
RATIO ( ratio for person)
FYI I have about 100 questions and 5000 people

Example :

ID_PERSON,ID_QUESTION,ANSWER
1,1,yes,ratio_person
1,2,OK,0,65
1,3,Problem,0,65
2,1,No,0,65
2,2 OK,0,65
2,3, Trouble
3,1,No,0,65
3,2 OK,0,65
3,3, Trouble,0,65
3,1,No,0,65
3,2 OK,0,65
3,3,No Problem,0,65


In my case My objective is to know that the people who answered Yes to question "x" (user can choose), answered question 1,3,... (i have 20 question preselected)

Example here, I have 2 people who answered "No" to question 1, they answered 100% OK to question Number "1"

==> Result
Trouble = 66%
NO Problem = 33%


in my formula, I would therefore have to retrieve, depending on the answer chosen to a question (Step 1), the number of answers to question 2 (fixed ID) only for people who answered what we are looking for


I try to explain it with un screen..

i've tried whey many compute but i didn't find it 😞 could you help me?) thank a lot

 

Sans titre.png

1 ACCEPTED SOLUTION
AmiraBedh
Super User
Super User

If possible, please share your pbix file, otherwise try the following :

 

AnswerDistribution =
VAR SelectedQuestion = 1 -- Replace with the question ID you want to filter
VAR SelectedAnswer = "No" -- Replace with the answer you want to filter
VAR FilteredPeople =
CALCULATETABLE(
VALUES('Survey'[ID_PERSON]),
'Survey'[ID_QUESTION] = SelectedQuestion,
'Survey'[ANSWER] = SelectedAnswer
)
VAR QuestionToAnalyze = 2 -- Replace with the question ID you want to analyze
VAR Result =
CALCULATE(
COUNT('Survey'[ANSWER]),
FilteredPeople,
'Survey'[ID_QUESTION] = QuestionToAnalyze
)
RETURN
IF(Result > 0, Result / COUNTROWS(FilteredPeople), BLANK())

Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

View solution in original post

2 REPLIES 2
Dpit
New Member

Sorry for the delay in response, I had to work on another point.

Thank you very much for your proposal which I tried to adapt without success.

But your code gave me an idea to modify the data upstream.

Thank you for your formula that I keep aside for next time, I didn't know we could do so much with dax 🙂

AmiraBedh
Super User
Super User

If possible, please share your pbix file, otherwise try the following :

 

AnswerDistribution =
VAR SelectedQuestion = 1 -- Replace with the question ID you want to filter
VAR SelectedAnswer = "No" -- Replace with the answer you want to filter
VAR FilteredPeople =
CALCULATETABLE(
VALUES('Survey'[ID_PERSON]),
'Survey'[ID_QUESTION] = SelectedQuestion,
'Survey'[ANSWER] = SelectedAnswer
)
VAR QuestionToAnalyze = 2 -- Replace with the question ID you want to analyze
VAR Result =
CALCULATE(
COUNT('Survey'[ANSWER]),
FilteredPeople,
'Survey'[ID_QUESTION] = QuestionToAnalyze
)
RETURN
IF(Result > 0, Result / COUNTROWS(FilteredPeople), BLANK())

Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors