Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Iterate Values from 2 different Tables to get Output Table

Hello;

I have two tables "Table_Req" and "Table_Cap", I need to find the EmployeeId's on "Table_Cap" matching ParameterKey for each "DemandId".  Some kind of iteration will be required.  Can you please help me to get the desired result?  Herein the dummy example for the data set and desired result:

 

Tables in the Data Model:

Table_Req
DemandIdParameterKey
123A
123B
123D
123F
234C
234D
234E
345E
345F
345G
456B
456C
456D

 

Table_Cap 
EmployeeIdParameterKey
XYZA
XYZB
XYZC
XYZD
XYZE
XYZF
WXYA
WXYB
WXYC
WXYD
VWXB
VWXC
VWXD
VWXE
VWXF
VWXG
UVWA
UVWB
UVWC
UVWD
UVWF

 

Desired Result:

Output _Table
DemandIdEmployeeMatch
123XYZ
123UVW
234XYZ
234VWX
345VWX
456XYZ
456WXY
456VWX
456UVW

 

Thanks in Advance;

WGAP75

  • Hi Anonymous ,

     

    You need a measure as below:

     

     

     

     

    Measure = IF(CALCULATE(COUNTROWS('Table_Req'),FILTER('Table_Req','Table_Req'[ParameterKey] in DISTINCT(Table_Cap[ParameterKey])))= COUNTROWS('Table_Req'),1,BLANK())

     

     

     

    Finally you will see:

     

     

    Pls note that dont create relationships between the 2 table,otherwise the measure will return error.

     

    For the related .pbix file,pls click here.

     

    Best Regards,
    Kelly
    Did I answer your question? Mark my post as a solution!
     

3 Replies

  • v-kelly-msft's avatar
    v-kelly-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    You need a measure as below:

     

     

     

     

    Measure = IF(CALCULATE(COUNTROWS('Table_Req'),FILTER('Table_Req','Table_Req'[ParameterKey] in DISTINCT(Table_Cap[ParameterKey])))= COUNTROWS('Table_Req'),1,BLANK())

     

     

     

    Finally you will see:

     

     

    Pls note that dont create relationships between the 2 table,otherwise the measure will return error.

     

    For the related .pbix file,pls click here.

     

    Best Regards,
    Kelly
    Did I answer your question? Mark my post as a solution!
     
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi v-kelly-msft;

      Thanks for your useful help provided with this solution, I've an additional question, How I can do if I need to perform aggregations with the results from the Measure?  I tried to COVERT / FORMAT the measure to Number but I don't manage to get a good result.

       

      Again your help is more than Welcome;

      WGAP75