Forum Discussion

ju_jacobowiski's avatar
ju_jacobowiski
Frequent Visitor
7 years ago
Solved

DAX - Right result but wrong individual flag.

Hey, guys. I've written a measure with DAX in order to check HOW MANY and WHICH questions meet certain criteria:

questions_block_N1_V1 = 
IF([%_compliance_trabalhista_red] <> 1,

(CALCULATE(
COUNT('5_es_individual_compliance'[id_question]),
'5_es_individual_compliance'[question_class] IN {"red"},
'5_es_individual_compliance'[compliance_status] IN {"False"}, 
'5_es_individual_compliance'[topic_txt] IN {"Trabalhista", "Empregados Próprios", "Consórcio", "Terceiros", "Prestadores de Serviço", "Prevenção de Riscos e Acidentes", "Solo", "Plantio", "MIP", "Adubação", "Gestão", "Queima", "Agroquímicos", "Recursos hídricos", "Floresta"})), 0) +

IF([%_compliance_trabalhista_purple] < 0.75,

(CALCULATE(
COUNT('5_es_individual_compliance'[id_question]),
'5_es_individual_compliance'[question_class] IN {"purple"},
'5_es_individual_compliance'[compliance_status] IN {"False"},
'5_es_individual_compliance'[topic_txt] IN {"Trabalhista"})), 0) +

IF([%_compliance_trabalhista_blue] < 0.5, 

(CALCULATE(
COUNT('5_es_individual_compliance'[id_question]),
'5_es_individual_compliance'[question_class] IN {"blue"},
'5_es_individual_compliance'[compliance_status] IN {"False"},
'5_es_individual_compliance'[topic_txt] IN {"Trabalhista"})))

For the example below, this function gives the result 2, which is correct. But when I add the list of questions to be flagged (so I get to know which ones are these 2), something goes wrong:

 

It should only show with "1" the questions circled in red. Not sure what I'm doing wrong here. Any help is really appreciated!

 

 

 

  • Hoi! It looks like you're trying to do quite some operations in that one big query... break it up into 3 dimensions for now and see what each one is answering... perhaps it's an ordering thing? I can't really tell because I can't understand the logic (since you haven't shown all the data.)

     

    If the problem is just in the last visual, you circled two reds and the answer is two... so is it perhaps just ADDING instead of taking the mean or something like that?

2 Replies