cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
The_Clam
Helper I
Helper I

Please help - Tricky column A greater than 25 or column B greater than 250 problem

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
1 ACCEPTED 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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
FarhanAhmed
Super User
Super User

Try

_Count = CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER('Table','Table'[A]>25 || 'Table'[B]>250))

 







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors