Dax Command for returning frequency of boolean (true/false) values

Hi everyone, I’m having a hard time finding a suitable dax command for returning the frequency of boolean values in my dataset. I used the COUNTAX(FILTER(‘Table’,[element_name]=TRUE()),TRUE()). It indeed worked, however, upon using filters, it is returning the original frequencies, rather than returning the values based on the selected filters.

Any help/guide is really appreciated.
Thanks for your responses in advance.

@prince.behordeun,

Try something along these lines:

Frequency =
CALCULATE(
	COUNTROWS (
		ALLSELECTED( Table )
	),
	FILTER(
		Table,
		[Column or Measure] = TRUE
	)
)

If that doesn’t get you what you need, please post your PBIX and I’ll be glad to work through a more specific solution with you.

I hope this is helpful.

  • Brian
2 Likes

Thanks @BrianJ, I will try it out and revert asap

Hi @prince.behordeun, did the response provided by @BrianJ help you solve your query? If not, how far did you get, and what kind of help you need further? If yes, kindly mark the thread as solved. Thanks!

Hey Brian, I believe ALLSELECTED should be a part of the FILTER instead of COUNTROWS:

Frequency =
CALCULATE (
    COUNTROWS ( Table ),
    FILTER ( ALLSELECTED ( Table[ColumnName] ), [Column or Measure] = TRUE )
)

HI @BrianJ and @AntrikshSharma,

I think even this will give the same results.

Frequency = 
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (  'Table' , 'Table'[Status] = TRUE )
)  

Wanted to understand do we really need an ALLSELECTED() in this case . Let me know your views.

Also I think the above code can be written as (incase we want to use COUNTAX)

Frequency = 

COUNTAX(FILTER('Table','Table'[ColumnName]=TRUE),'Table'[ColumnName])

Regards,
Harsh Nathani

Nope, it did not solve the problem.

@harsh.nathani, I already tried the COUNTAX

EDNA Challenge 2.pbix (407.9 KB) Kindly find attached the pbix file. Please do not mind the visualizations, I’m more concerned about the DAX for now

Hello @prince.behordeun,

Can you please provide us some information against which measure/fields you’re trying to achieve the desired result because in the given file there are too many measures and fields it’s hard to find out what you were looking for from the given file.

Thanks & Warm Regards,
Harsh

I am trying to get the count of opened/unopened email for each product, however, instead of each product having it’s unique value, all products are having the same value (which I don’t think is right)

Hi @prince.behordeun,

This is because the Table Email and Table Products are not related at all.

A customer receives an email but you can not conclude that the email was sent for a particular product.

Hence it will not be possible to count the number of emails sent/opened/not opened for a particular product.

Regards,
Harsh Nathani

1 Like

@harsh.nathani, thanks I figured that out also, however, I wanted to be sure that I’m not missing anything out. Thanks for your time, I’m really grateful :pray: