Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

columns and tables

hi everyone, 

i have the following table provided.

 

every material should have a unique material number. If there are more than one material number for a material, a table like  the following table should inform the user

 

 

thanks in advance

  • Perhaps something like:

     

    Measure = 
    VAR __table = SUMMARIZE('Table',[Material],[MaterialNumber])
    RETURN
    COUNTROWS(__table)

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Perhaps something like:

     

    Measure = 
    VAR __table = SUMMARIZE('Table',[Material],[MaterialNumber])
    RETURN
    COUNTROWS(__table)
    • Anonymous's avatar
      Anonymous
      Not applicable

      Greg_Deckler  Thanks it works!

      I am trying to understand the solution. Why does it work. 

      Summarize actually return a table with two columns: Material and MaterialNumber.  

      So the COUNTROWS( ) function counts the rows of the first column of the VAR __table?

      • Greg_Deckler's avatar
        Greg_Deckler
        Icon for Community Champion rankCommunity Champion

        Well, it works because SUMMARIZE returns distinct results for each summarized column. So, because you are summarizing by 2 columns, you are essentially going to get back a table with all of the distinct combinations of those two columns. Now, in the context of having material, this means that any material that has 2 material numbers will return 2 rows, because there are 2 unique material numbers for that material. However, if you put this measure in the context of material and material number, I don't think it would work necessarily.