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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
toneradeu
New Member

Using COUNTROWS to find the amount of times the given [Code] appears in a table

Greetings, I started using Power BI recently, so I don't have experience in DAX, and i'm stuck in a problem that i can't really think of a solution.

 

  • I have this gigantic table called 'fResponsib' which have a Column named [Responsibility_Name].
  • I also have a Table called 'DimEnt', which has 2 columns: [Code] and [Flag].
  • I need to create an column called [Qty] in 'DimEnt, which is the sum of all the times [Code] has appeared in [Responsibility_Name].
  • Both [Code] and [Responsibility_Name] are text-values.

Here's what i had in mind:

 

CodeFlagQty
F4XX45Type-A813
F4XX06Type-B755
F4XX15Type-C9
F4XX87Type-D114
F4XX33Type-E887
 Other33133

 

What I tried to do:

Qty = COUNTROWS( CALCULATETABLE('fResponsib', CONTAINSSTRING('fResponsib'[Responsibility_Name],'DimEnt'[Code])))

 

What should I do in this situation?
Thanks in advance!

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@toneradeu 

Can you try this as a new column?

Qty = 
COUNTROWS( 
    FILTER(
        'fResponsib',
        CONTAINSSTRING('fResponsib'[Responsibility_Name],EARLIER([Code]))
    )
)

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

1 REPLY 1
Fowmy
Super User
Super User

@toneradeu 

Can you try this as a new column?

Qty = 
COUNTROWS( 
    FILTER(
        'fResponsib',
        CONTAINSSTRING('fResponsib'[Responsibility_Name],EARLIER([Code]))
    )
)

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.