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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ju_jacobowiski
Frequent Visitor

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:

bug_powerbi.png

 

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

 

 

 

1 ACCEPTED SOLUTION
akohli
New Member

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?

View solution in original post

2 REPLIES 2
akohli
New Member

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?

I closed this topic because it was duplicated, gonna concentrate this discussion here: https://community.powerbi.com/t5/Desktop/Result-of-measure-is-correct-but-it-s-flagging-wrongly/m-p/...

 

Cheers!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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