Forum Discussion
Dpit
3 years agoNew 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 hav...
- 3 years ago
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())
AmiraBedh
Super User
3 years agoIf 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())