Forum Discussion

jvirgi's avatar
jvirgi
Icon for Helper III rankHelper III
6 years ago
Solved

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 -...
  • Anonymous's avatar
    Anonymous
    6 years ago

    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
            )
        )

    Best Regards

    Rena