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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
esiniapkina
Frequent Visitor

Finding the amount of values in table 1 that are matching values from table 2

Hi 

I am trying to find equivalent of Excel formula in DAX:

Count how many specific words (from keywords table) is in mentioned in a cell from the range from different table 

=SUMPRODUCT((LEN(txt)-LEN(SUBSTITUTE(UPPER(txt),UPPER(range),""))) / LEN(UPPER(range)))

 

So i am kinds looking for solving similar task with matching words from different table:

 

 I need similar formula but it should show me the number of words, not just TRUE or FALSE

 [Is this company a metals company] =

  =IF(
      SUMX(MatchList,
           FIND(
                UPPER(MatchList[Keyword]),
                UPPER(Companies[Company])
                ,,0
               )
          ) > 0,
      “YES!”,
      “Probably Not”
     )

 Thank you

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

HI,@esiniapkina

     After my research, you can do these follow my steps as below:

Step 1:

add index column in Edit Queries and then add a calculate column:

Hasvalue = SUMX(MatchList,
           FIND(
                UPPER(MatchList[Keyword]),
                UPPER(Companies[Company])
                ,,0
               )
          )

8.PNG

Step2:

Cross join the two table

Table = CROSSJOIN(Companies,MatchList)

Step3;

add these column

Sub = SUBSTITUTE('Table'[Company],'Table'[Keyword],"")

Count = (LEN('Table'[Company])-LEN('Table'[Sub]))/LEN('Table'[Keyword])

C1 = 
           FIND(
                
                UPPER('Table'[Keyword])
                ,UPPER('Table'[Company]),,0
               )
          

C2 = IF('Table'[Hasvalue]>0&&'Table'[Company]='Table'[Sub],1,2)

Step 4

use this formula to get result table

Table 2 = CALCULATETABLE(SUMMARIZE('Table','Table'[Company],'Table'[Value],'Table'[Is this company a metals company],'Table'[Hasvalue],'Table'[Sub],'Table'[Count],'Table'[C1],'Table'[Index]),'Table'[C2]=2)

Result:

9.PNG

here is pbix, please try it.

https://www.dropbox.com/s/8bqgqaacokqmyrw/Finding%20the%20amount%20of%20values%20in%20table%201%20th...

 

Best Regards,

Lin

 

 

 

Community Support Team _ Lin
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

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

HI,@esiniapkina

     After my research, you can do these follow my steps as below:

Step 1:

add index column in Edit Queries and then add a calculate column:

Hasvalue = SUMX(MatchList,
           FIND(
                UPPER(MatchList[Keyword]),
                UPPER(Companies[Company])
                ,,0
               )
          )

8.PNG

Step2:

Cross join the two table

Table = CROSSJOIN(Companies,MatchList)

Step3;

add these column

Sub = SUBSTITUTE('Table'[Company],'Table'[Keyword],"")

Count = (LEN('Table'[Company])-LEN('Table'[Sub]))/LEN('Table'[Keyword])

C1 = 
           FIND(
                
                UPPER('Table'[Keyword])
                ,UPPER('Table'[Company]),,0
               )
          

C2 = IF('Table'[Hasvalue]>0&&'Table'[Company]='Table'[Sub],1,2)

Step 4

use this formula to get result table

Table 2 = CALCULATETABLE(SUMMARIZE('Table','Table'[Company],'Table'[Value],'Table'[Is this company a metals company],'Table'[Hasvalue],'Table'[Sub],'Table'[Count],'Table'[C1],'Table'[Index]),'Table'[C2]=2)

Result:

9.PNG

here is pbix, please try it.

https://www.dropbox.com/s/8bqgqaacokqmyrw/Finding%20the%20amount%20of%20values%20in%20table%201%20th...

 

Best Regards,

Lin

 

 

 

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

@v-lili6-msft million of thanks! it worked out

simply genious solution

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.