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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
jvirgi
Helper III
Helper III

Calculating Measures by Searching text in another table

I'd like to create measures to calculate the counts of Sports within AllSports from Table 1 as well as then average rating and sentiment for each of the Sports in Table 2.  For example for football - the count is 2, avg rating is 4, avg sentiment is 0.2.

 

I wanted to calculate these measures so that i can then create a bubble chart showing each sport, sized by the count, and with the avg rating and sentiment on my x and y axes.

 

I don't want to create a measure to count for each sport, because then there may be a ton of measures.

 

@ImkeF I had seen you had a number of similar solutions for other people but i couldnt figure how to adapt for my case.

 

Table 1:

RatingSentimentAllSports
40.6Hockey, Frisbee, Golf
50.3Golf, Tennis
30.2Rugby, Hockey
50.5Golf
30.3Football
50.1Football, Golf

 

Table 2: 

Sports
Hockey
Frisbee
Golf
Tennis
Rugby
Football
1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @jvirgi ,

You can create 2 measures for calculating average of rating and sentiment as below:

Avg rating = 
SUMX (
    FILTER (
        'Table 1',
        SEARCH ( MAX ( 'Table 2'[Sports] ), 'Table 1'[AllSports], 1, 0 ) > 0
    ),
    'Table 1'[Rating]
)
    / COUNTROWS (
        FILTER (
            'Table 1',
            SEARCH ( MAX ( 'Table 2'[Sports] ), 'Table 1'[AllSports], 1, 0 ) > 0
        )
    )
Avg sentiment = 
SUMX (
    FILTER (
        'Table 1',
        SEARCH ( MAX ( 'Table 2'[Sports] ), 'Table 1'[AllSports], 1, 0 ) > 0
    ),
    'Table 1'[Sentiment]
)
    / COUNTROWS (
        FILTER (
            'Table 1',
            SEARCH ( MAX ( 'Table 2'[Sports] ), 'Table 1'[AllSports], 1, 0 ) > 0
        )
    )

Calculating Measures by Searching text in another table.JPG

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi @jvirgi ,

You can create 2 measures for calculating average of rating and sentiment as below:

Avg rating = 
SUMX (
    FILTER (
        'Table 1',
        SEARCH ( MAX ( 'Table 2'[Sports] ), 'Table 1'[AllSports], 1, 0 ) > 0
    ),
    'Table 1'[Rating]
)
    / COUNTROWS (
        FILTER (
            'Table 1',
            SEARCH ( MAX ( 'Table 2'[Sports] ), 'Table 1'[AllSports], 1, 0 ) > 0
        )
    )
Avg sentiment = 
SUMX (
    FILTER (
        'Table 1',
        SEARCH ( MAX ( 'Table 2'[Sports] ), 'Table 1'[AllSports], 1, 0 ) > 0
    ),
    'Table 1'[Sentiment]
)
    / COUNTROWS (
        FILTER (
            'Table 1',
            SEARCH ( MAX ( 'Table 2'[Sports] ), 'Table 1'[AllSports], 1, 0 ) > 0
        )
    )

Calculating Measures by Searching text in another table.JPG

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yiruan-msft Thanks! This is exactly what i was looking for. 

 

However i notice when i  also try to make a donut chart of the breakout of the Count of sports, i dont get anything when i use Table2[Sports] as my legend and the countrows measure as my Values. 

 

Not sure if this is why but when i just create a matrix table for Sport, Count of sports, Avg rating, Avg sentiment,  the table totals shows the value from only the final row in the table rather than an average across all rows.

@v-yiruan-msft   Actually it was my mistake, the donut chart worked fine... i had it setup wrong.  

 

But do you know why the matrix table totals show only the final rows value?

camargos88
Community Champion
Community Champion

Hi @jvirgi ,

 

I've created this file as an example: Download PBIX 

 

I used Power Query to split the sport in new rows.

 

Ricardo



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

Proud to be a Super User!



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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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