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. 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
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 |
---|---|
108 | |
98 | |
78 | |
66 | |
53 |
User | Count |
---|---|
139 | |
100 | |
95 | |
85 | |
63 |