Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Evaluating if two fields (from separate tables) equal in DAX

I am trying to count a field if two fields are equal. I think the problem is the two fields are in separate tables. However the appropriate joins are in place that create a relationship between these fields/tables.

 

The expression I am trying to write (but it doesn't work):

 

Optimization = CALCULATE(countx(ITEM,ITEM[RecommendedStrategy]),FILTER(ITEM,ITEM[RecommendedStrategy]=STRATEGY[Actual Strategy]))

 

 

  • Anonymous's avatar
    Anonymous
    8 years ago

    Anonymous,

    Create the following column in your ITEM table.

    Column = LOOKUPVALUE(STRATEGY[Actual Strategy],STRATEGY[Actual Strategy],'ITEM'[RecommendedStrategy])


    Then create the following measure in the ITEM table.

    Optimization = CALCULATE(COUNTROWS('ITEM'),FILTER('ITEM','ITEM'[RecommendedStrategy]='ITEM'[Column]))



    Regards,
    Lydia

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Anonymous,

    Create the following column in your ITEM table.

    Column = LOOKUPVALUE(STRATEGY[Actual Strategy],STRATEGY[Actual Strategy],'ITEM'[RecommendedStrategy])


    Then create the following measure in the ITEM table.

    Optimization = CALCULATE(COUNTROWS('ITEM'),FILTER('ITEM','ITEM'[RecommendedStrategy]='ITEM'[Column]))



    Regards,
    Lydia

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

    Anonymous Could you please post sample data for resolving your issue.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Where is the icon to attach an excel file?

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi

     

    Please try RELATED in your formula.

     

    RELATED ( STRATEGY[Actual Strategy]) )

     

    Thanks
    Raj

    • Anonymous's avatar
      Anonymous
      Not applicable

      Can't get that to work.