Forum Discussion

DaveRaul's avatar
DaveRaul
New Member
9 years ago

Count IF between 2 tables

Hey,

 

I've tried to create a new table (table1) for counting links, if they are in the other table ( the libary-table).

If the links are in the libary, I want to know how often they are in table1.

See the picture from excel: 

Screen1

Please mind, that the libary has only the "main-parts" of the links. So I guess we have to work with asterisks.

 

Many thanks in advance,

Nick

4 Replies

  • Hey,

     

    I want to count the target - URL's, if they exist in the Libary-table. Please see the image below:

     

    I thought I can handle this with a new table and the summarize-function, but I'm stuck. I don't really care, if I have to add a new column or a new table or just a measure. The main part is, that this function has to work :-)

     

    Many thanks in advance,

    Dave

  • v-qiuyu-msft's avatar
    v-qiuyu-msft
    Community Support

    Hi DaveRaul,

     

    You can create a calculated columns in the table like below:

     

    Column = var t=LEFT('Table1'[Target - URL],SEARCH("/",'Table1'[Target - URL])-1)
    return
    RIGHT(t,LEN(t)-SEARCH(".",t))

     

    Count = IF( RELATED( 'Library'[Library -  URL] ) <> BLANK(), CALCULATE( COUNTROWS( Table1 ), ALLEXCEPT( Table1, Table1[Column] ) ) ) 

     

     

     

    Best Regards,
    Qiuyun Yu

    • DaveRaul's avatar
      DaveRaul
      New Member

      Thank you very much for the answer.

       

      I tried your code but it does not work properly :-/

      I got the following problem:

      If the string is extactly the same or of it is seperated by '/', it does work, .

      But the code has to recognize the Url, if the Url just contains the library-Url-String. 

      In Excel one can write an asterisk like: if("cde"="*d*","Yes","No")

      in this case i want the response "Yes", but your code deliveres for this case "No".

       

      I realised this wasn't exactly formulated. Sorry for that.

      • v-qiuyu-msft's avatar
        v-qiuyu-msft
        Community Support

        Hi DaveRaul,

         

        In DAX, it doesn't have function perform as wildcards. The DAX provided in my previous reply is based on your sample data, as you mentioned it will not work, can you please share the sample to clarify which scenario doesn't work?

         

        Best Regards,
        Qiuyun Yu