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 Everyone,
I'm trying to write a DAX expression in the pivot table and I could not figured out how to use the combination of Calculate, Filter & Count.
I need to exclude all User that has 1 or less transaction - I currently have this expression but the result is not correct:
=if(
count([Type]) > 1, COUNT([Type]),
blank())
The Data is as follows:
Department | User | Symbol | Type |
A1 | AAA | TSLA | Buy |
A1 | AAA | TSLA | Buy |
A1 | CCC | BCE | Buy |
A1 | DDD | PWC | Buy |
B1 | AAA | HBT | Sell |
B1 | BBB | BCE | Buy |
B1 | BBB | HDS | Sell |
Output should be, note User "CCC" & "DDD" are not populated because it has only 1 count:
Department | User | Type | Symbol | Count |
A1 | AAA | Buy | TSLA | 2 |
Sell | HBT | 1 | ||
B1 | BBB | Buy | BCE | 1 |
Sell | HDS | 1 |
Hope you can help!
[Exclude User] =
var __userFiltered = ISFILTERED( Data[User] )
var __oneUserVisible = HASONEVALUE( Data[User] )
var __totalTranCount =
CALCULATE(
COUNTROWS( Data ),
ALLEXCEPT( Data, Data[User] )
)
var __shouldExclude = __totalTranCount <= 1
var __finalCondition =
__userFiltered
&& __oneUserVisible
&& __shouldExclude
return
if( __finalCondition, __shouldExclude )
This measure tells you if you should exclude the user (TRUE) or not (FALSE). You can put this measure in your pivot and filter by it leaving only those users for which the measure returns FALSE (meaning: don't exclude).
Best
D
Maybe:
Measure =
VAR __Table =
SELECTCOLUMNS(
FILTER(
SUMMARIZE(
ALL('Table'),
[User],
"__Count',COUNTROWS('Table')
),
[__Count] < 2
),
"User",
[User]
)
RETURN
IF(MAX('Table'[User] IN __Table,0,1)
Then use that as a filter.
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 |
---|---|
47 | |
24 | |
20 | |
14 | |
12 |
User | Count |
---|---|
55 | |
48 | |
43 | |
19 | |
18 |