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.
I've seen boolean calculations using filters like this:
trues_count = CALCULATE( COUNT([Element A]), FILTER(Table, [Element A] = "True"))
Since I'm using more filters I need more control on those counts, which could resemble otther languages that treat TRUE as 1 and FALSE as 0.
For example,
A5_proportion = CALCULATE( AVERAGE(Table[indicator A] <= 5), Table[Filter B], TREATAS( VALUES(Calendar[date] ), Table[event_date]) )
This isn't possible because AVERAGE requires a column.
Does anyone know a good way to achieve this? Thanks.
If you want to average an expression evaluated over each row of a table, you can use the iterator AVERAGEX.
Also, in DAX, booleans are not automatically cast as numbers, but you can multiply by 1 or add 0 to achieve the same effect.
An expression which I think achieves what you want, in place of AVERAGE(Table[indicator A] <= 5), is
AVERAGEX ( Table, ( Table[indicator A] <= 5 ) + 0 )
Regards,
Owen
Thanks for this hint.
I shall mark this as a solution.
Still, I'm missing how to combine regular filters with virtual ones from TREATAS.
I'll post a new message.
Cheers.
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 |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |