Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi. I need some help please.
I would like a count of ID if column A is greater than 25 or column B is greater than 250. The two tricky parts I cannot quite grasp are: 1) If both conditions are TRUE, then it should only count as 1, not 2. And 2) There are duplicate IDs in the dataset, so the SUM of these IDs should be above the thresh-hold, not individually.
I have attached a link to the Power BI file. For the dataseset in the file, the number I am looking for is: 24
Thanks!
Power BI file:
https://drive.google.com/file/d/11GRAerF7N79UY-OrOX_7DqzrpktoLLc6/view?usp=sharing
Small sample of dataset:
Index | ID | A | B | |||
1 | 28483 | 30 | 0 | |||
2 | 28629 | 0 | 1469905 | |||
3 | 28631 | 0 | 1469907 | |||
4 | 28987 | 40 | 0 | |||
5 | 28989 | 50 | 0 | |||
6 | 29023 | 8 | 0 | |||
7 | 29035 | 8 | 0 | |||
8 | 29203 | 1 | 0 | |||
9 | 29205 | 1 | 0 | |||
10 | 29213 | 1 | 0 | |||
11 | 29215 | 1 | 0 | |||
12 | 29343 | 8 | 0 | |||
13 | 29429 | 1 | 0 | |||
14 | 29433 | 8 | 0 | |||
15 | 29441 | 14 | 0 | |||
16 | 29441 | 13 | 0 | |||
17 | 29443 | 1 | 0 | |||
18 | 29443 | 1 | 0 | |||
19 | 29443 | 1 | 0 | |||
20 | 29445 | 1 | 0 |
Solved! Go to Solution.
Hi @The_Clam,
So you mean these conditions are checking the aggregated fields value based on the current id group? If that is the case, you can create a variable to summarize these value fields and calculate with filtered values.
_Count =
VAR summary =
SUMMARIZE (
FILTER ( 'Table', [ID] = EARLIER ( 'Table'[ID] ) ),
[ID],
"Total_A", SUM ( 'Table'[A] ),
"Total_B", SUM ( 'Table'[B] )
)
RETURN
COUNTROWS ( FILTER ( summary, [Total_A] > 25 || [Total_B] > 250 ) )
Regards,
Xiaoxin Sheng
Try
_Count = CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER('Table','Table'[A]>25 || 'Table'[B]>250))
Proud to be a Super User!
Thank you for your reply. That almost gets me there but not quite. That measure gets me 22. I need 24. The problem is there are multiple IDs (2 sets in fact), so if the combined IDs are over the threshhold then it should be counted. I have updated the power bi file to include an index.
Hi @The_Clam,
So you mean these conditions are checking the aggregated fields value based on the current id group? If that is the case, you can create a variable to summarize these value fields and calculate with filtered values.
_Count =
VAR summary =
SUMMARIZE (
FILTER ( 'Table', [ID] = EARLIER ( 'Table'[ID] ) ),
[ID],
"Total_A", SUM ( 'Table'[A] ),
"Total_B", SUM ( 'Table'[B] )
)
RETURN
COUNTROWS ( FILTER ( summary, [Total_A] > 25 || [Total_B] > 250 ) )
Regards,
Xiaoxin Sheng
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
65 |
User | Count |
---|---|
135 | |
118 | |
101 | |
71 | |
61 |