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.
Hi All,
I have a data set that looks something like this:
Date | Name | T or F |
18/11/2020 | A | T |
18/11/2020 | B | T |
19/11/2020 | A | T |
19/11/2020 | B | F |
How should I go about writing a DAX formula if I want to know the percentage of times there is T for a certain name. For example, I would like to write a measure for A which equals 100%, and a measure for B which is 50%. Any help would be appreciated. Thanks
Hi, @7ea8ea
You can try measure as below:
Count_T =
VAR a =
COUNTX ( FILTER ( 'Table', 'Table'[T or F] = "T" ), 'Table'[Date] )
RETURN
IF ( ISBLANK ( a ), 0, a )
Count = COUNTX('Table', 'Table'[Date])
Percentage% = [Count_T]/[Count]
Check sample file for more details.
Best Regards,
Community Support Team _ Eason
@7ea8ea , Try measures for
A
calculate( divide(countx(filter(table, table[T of F] ="T"), Table[Date]), countx(Table, Table[Date])) , Table[Name] ="A")
or
calculate( divide(countx(filter(table, table[T of F] ="T"), Table[Date]), countx(allselected(Table), Table[Date])), Table[Name] ="A")
for B
calculate( divide(countx(filter(table, table[T of F] ="T"), Table[Date]), countx(Table, Table[Date])) , Table[Name] ="B")
or
calculate( divide(countx(filter(table, table[T of F] ="T"), Table[Date]), countx(allselected(Table), Table[Date])), Table[Name] ="B")
Hi, thanks for the quick response. I tried using the formula you have stated but it doesn't seem to work. Maybe it's because my data has more names and dates? (I have thousands of rows). Any possible reason as to why this formula will not work for my data?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
100 | |
80 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
93 | |
84 | |
66 |