Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
newbie_but_conf
Helper II
Helper II

Distinct number of rows with certain description

Hi,

 

I'm sure this has been asked before, but couldnt find anything that worked for me. 

I have something that looks like this table:

 

IDDescriptionNumber
1Message1
1Search1
1Else2
1Complain2
1Message3
1Search4
2Message1
2Search2
2Else2
2Complain2
3Message2
3Search2
3Else3
3Complain4
3Message4

 

I would like to get the total number of rows when Description is "Message" or "Search", but only count 1 row, when both happen and ID and number are equal. 
I've tried something like this:

 

 

 

Distinct rows = 
CALCULATE(
    DISTINCTCOUNT('Table1'[Number]),
    'Table1'[Description] in {"Message", "Search"},
    GROUPBY('Table1', 'Table1'[ID])
)

 

 

 

 

When I filter by ID, it seems to work as expected, however, when I try to get the total number of rows it just adds the distinct number. I've also tried to get just get the count, but that returns more rows than what I'm looking for.. 

 

As an example I expect a total count of 7 for the table I've added. That means counting just 1 for ID 1 with number 1 and counting 1 for ID 3 and Number 2.

 

Hope it makes sense.

 

Thanks!

1 ACCEPTED SOLUTION
tackytechtom
Super User
Super User

Hi @newbie_but_conf,

 

How about this? 🙂

Distinct rows = 
VAR _helpTable = 
SUMMARIZE (
    Table3,
    Table3[ID],
    Table3[Number],
    "CountMesSearch", CALCULATE ( COUNTROWS ( Table3 ), Table3[Description] in {"Message", "Search"} )
)
RETURN
COUNTROWS ( FILTER ( _helpTable, [CountMesSearch] <> BLANK() ) )

tackytechtom_0-1705525954200.png

 

 

Let me know if this solves your issue 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

2 REPLIES 2
tackytechtom
Super User
Super User

Hi @newbie_but_conf,

 

How about this? 🙂

Distinct rows = 
VAR _helpTable = 
SUMMARIZE (
    Table3,
    Table3[ID],
    Table3[Number],
    "CountMesSearch", CALCULATE ( COUNTROWS ( Table3 ), Table3[Description] in {"Message", "Search"} )
)
RETURN
COUNTROWS ( FILTER ( _helpTable, [CountMesSearch] <> BLANK() ) )

tackytechtom_0-1705525954200.png

 

 

Let me know if this solves your issue 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Just what I was looking for! Thank you!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.