Forum Discussion
Convert True False and Count - DAX Help
- 8 years ago
Hi Anonymous,
1. Since your column is a state type you need to use the FALSE() / TRUE() formulas and not the text "FALSE"/"TRUE" so in this case you would use something like this:
Completed = IF(Table[Status]=FALSE(), "Incomplete","Complete")
2. You have several ways of doing this:
a) Add the Completed column previously calculated on a visual and then select in the filter the status you need to count.
b) Add the following measure be aware that this is a hard coded filter so if you need to change any filter on this you have to rewrite your measure however no need to have :
Count_completed_ = CALCULATE(COUNT('Table'[Completed]),'Table'[Completed]="Complete")c) Add the following measure to your model, but if you only want to get one of the values you need to put in place the visual filter as it's done in the a), this is a more dinamic measure since you can have several states in your visual if you use the b) option you will be restricted to one state. (as you can see below this measure allow you to use more than one value at a time.
Count_Complete = VAR count_status = COUNT ( 'Table'[Completed] ) RETURN CALCULATE ( count_status, 'Table'[Completed] = VALUES ( 'Table'[Completed] ) )Below are the examples for each of the options:
Regards,
MFelix
Hi Anonymous,
1. Since your column is a state type you need to use the FALSE() / TRUE() formulas and not the text "FALSE"/"TRUE" so in this case you would use something like this:
Completed = IF(Table[Status]=FALSE(), "Incomplete","Complete")
2. You have several ways of doing this:
a) Add the Completed column previously calculated on a visual and then select in the filter the status you need to count.
b) Add the following measure be aware that this is a hard coded filter so if you need to change any filter on this you have to rewrite your measure however no need to have :
Count_completed_ = CALCULATE(COUNT('Table'[Completed]),'Table'[Completed]="Complete")c) Add the following measure to your model, but if you only want to get one of the values you need to put in place the visual filter as it's done in the a), this is a more dinamic measure since you can have several states in your visual if you use the b) option you will be restricted to one state. (as you can see below this measure allow you to use more than one value at a time.
Count_Complete =
VAR count_status =
COUNT ( 'Table'[Completed] )
RETURN
CALCULATE ( count_status, 'Table'[Completed] = VALUES ( 'Table'[Completed] ) )Below are the examples for each of the options:
Regards,
MFelix
- Anonymous8 years agoNot applicable
Thanks MFelix !
This is awesome. These answers are what makes the community so positive. Really appreciate it.
One last question...
Is there a way to conditionally format the value of Complete and Incomplete i.e. Green / Red Text?
Thanks.
- MFelix8 years agoSuper User
Hi Anonymous,
The conditional formating is only possible in numbers, not with text you can use this other reply I used for another similar question.
Regards,
MFelix
- charleshale6 years agoContinued Contributor
I would love to see a less processor-intensive way to do this calc.