Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi,
I've been trying to solve an issue and I think I found a solution, however, I'm not sure it's the most efficient one.
I have a table where I have columns with True or False values.
TableA
ID | Column1 | Column2 | Column2 |
1 | TRUE | FALSE | TRUE |
2 | FALSE | FALSE | TRUE |
3 | TRUE | FALSE | TRUE |
4 | FALSE | TRUE | FALSE |
What I would like to do, is to have a vizualisations where I can check the total number of TRUE and FALSE for each column.
I though that it's possible to do it automatically in a vizualisation, however, it seems that it's not and I'm trying to solve this using DAX.
What I did was:
I created a new table.
I manually typed in True and False in the first column and then used DAX formula to populate the rest of the columns.
This is the result I got:
TableB
True_False | Column1 | Column2 | Column3 |
TRUE | 2 | 1 | 3 |
FALSE | 2 | 3 | 1 |
The formula I used to calculate the total number of TRUE or FALSE in table B:
Column1 =
CALCULATE(
COUNTROWS(
TableA),
FILTER(
TableA,
TableA[Column1] = TableB[True_False] )
)
I have two questions:
1) Is this the best way to do it?
2) Now I need to get for each column the percentage of TRUE values. What would be the best way to do it?
Thanks a lot!
In edit query
Change the column1,2,3 to a text data type
Click on the ID column > Transform > unpivot column > unpivot other column
Then add Dax measures
Total count = COUNTROWS('Table')
Total true = CALCULATE( [Total count], 'Table'[Value] = "TRUE" )
% = DIVIDE('Table'[Total true],'Table'[Total count])
User | Count |
---|---|
42 | |
28 | |
23 | |
18 | |
15 |
User | Count |
---|---|
54 | |
35 | |
18 | |
18 | |
15 |