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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Counting the number of times a word appears in a combined table

Hi all,

 

I got the Gland data from a table called datasheet and the rest of the data from a table called cable schedule and formed a relatioship with its ID. I would like to get the number of times the cable gland appears the combined table below.

eg. A240L    5

      CW40L  3

 

Capture.JPG

 

How can I do that?

 

Thanks.

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Anonymous - If I understand correctly, you want MC Aggregations - https://community.powerbi.com/t5/Quick-Measures-Gallery/Multi-Column-Aggregations-MC-Aggregations/m-p/391698#M129

 

To elaborate, I'm thinking something like:

Measure =
  VAR __Gland = MAX('Table'[Gland]) //get the current value of the thing you are trying to find
  VAR __Table = 
    UNION(
      SELECTCOLUMNS(ALL('Table'),"Column",[Gland]),
      SELECTCOLUMNS(ALL('Table'),"Column",[Gland 2])
    )
RETURN
  COUNTROWS(FILTER(__Table,[Column] = __Gland))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@Greg_Deckler 

 

Apologies, I know I have already marked it as a solution but I can't seem to get it right. 

 

I tried 

VAR tmpCol1 = SELECTCOLUMNS(Datasheet,"Column",[Gland])

VAR tmpCol2 = SELECTCOLUMNS('Cable Schedule',"Column",[ID])

VAR tmpTable = UNION(tmpCol1,tmpCol2)

VAR tmpValue = COUNTX(tmpTable,[Column])

 

(this doesnt give me the correct values)

and 

 

VAR Gland = ('Datasheet'[ID]) //get the current value of the thing you are trying to find
VAR Table =
UNION(
SELECTCOLUMNS(ALL('Cable Schedule'),"Column",[ID]),
SELECTCOLUMNS(ALL('Datasheet'),"Column",[Gland])
)
RETURN
COUNTROWS(FILTER(Table,[Column] = Gland))
 
While this just doesn't work with the error message 'syntax for Table is incorrect' and 'cannot find name 'ID'
 
 
 
Capture.JPG
 
I have included my field window as well.
 
Appreciate your help
Greg_Deckler
Super User
Super User

@Anonymous - If I understand correctly, you want MC Aggregations - https://community.powerbi.com/t5/Quick-Measures-Gallery/Multi-Column-Aggregations-MC-Aggregations/m-p/391698#M129

 

To elaborate, I'm thinking something like:

Measure =
  VAR __Gland = MAX('Table'[Gland]) //get the current value of the thing you are trying to find
  VAR __Table = 
    UNION(
      SELECTCOLUMNS(ALL('Table'),"Column",[Gland]),
      SELECTCOLUMNS(ALL('Table'),"Column",[Gland 2])
    )
RETURN
  COUNTROWS(FILTER(__Table,[Column] = __Gland))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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