Forum Discussion

esingh's avatar
esingh
Helper I
1 year ago

DAX Calculation: multiple tables

Hi Fabric Community,

 

I am new to Power BI and facing issues to create a dax calculation to achieve the following result:

From table 1 for insitution ABC, id 10, header string='A' we need to pick out responsecount=14012333 and divide it by values from the table 2 with following inputs institution ABC, Sum of values for Optionstring= 'Direct Costs' and 'Indirect Costs" and headerstring='aa' and 'bb'  which means= 46 dollars( 13+16+4+13) refered filtered table 2

I am looking for the values of  1401233/46.

 

Table1:

Table 2:

 

Filtered Table2:

 

Thanks

Ekam

 

5 Replies

  • BIswajit_Das's avatar
    BIswajit_Das
    Impactful Individual

    Hello esingh 
    As per your explanation & requirement you can try the below DAX but There might be a problem afterwards cause as you explained all the filter values are hardcoded in to the DAX.
    It Means This DAX only work for mentioned filters It means the values are specified.

    Thanks & Regards...

    • esingh's avatar
      esingh
      Helper I

      Tanks Biswajit , But the data need to vary based on the insitute. filter remain fixed.

      Ekam

  • pls paste the sample data here (not the screenshot). What about the rest ,e.g. DEF? also get the value from table 2 with only "aa" and "bb" in the Direct Costs' and 'Indirect Cost"?

    • esingh's avatar
      esingh
      Helper I

      Hi Ryan Mayu, You are right in your interpretation we need to get the data for DEF as well. I have just kept data of two institutes in table 2 for the purpose. Filter values remain unchanged, institute changes(dynamic). Sample data.

      idoptionStringheaderStringresponseCountinstitution_nameinstitution_code
      10xxA1401233ABC10
      10xxA1401000DEF20
      10yyA0GHI30
      10yyA0JKL40
      10xxB59ABC10
      10xxB53DEF20
      10yyB0GHI30
      10yyB0JKL40

       

      Table 2:
      idoptionStringheaderStringresponseCountinstitution_nameinstitution_code
      4Expendituresaa$15ABC10
      4 Expendituresbb$18ABC10
      4Expenditurescc$12ABC10
      4Direct Costsaa$13ABC10
      4Direct Costsbb$16ABC10
      4Direct Costscc$11ABC10
      4Indirect Costsaa$4ABC10
      4Indirect Costsbb$13ABC10
      4Indirect Costscc$2ABC10
      4Assetsaa$10ABC10
      4 Assetsbb$12ABC10
      4Assetscc$8ABC10
      4Labor Expense aa$20ABC10
      4Labor Expense bb$64ABC10
      4Labor Expense cc$13ABC10
      4Expendituresaa$15DEF20
      4 Expendituresbb$18DEF20
      4Expenditurescc$12DEF20
      4Direct Costsaa$13DEF20
      4Direct Costsbb$16DEF20
      4Direct Costscc$11DEF20
      4Indirect Costsaa$4DEF20
      4Indirect Costsbb$13DEF20
      4Indirect Costscc$2DEF20
      4Assetsaa$10DEF20
      4 Assetsbb$12DEF20
      4Assetscc$8DEF20
      4Labor Expense aa$20DEF20
      4Labor Expense bb$64DEF20
      4Labor Expense cc$13DEF20

       

       

      • ryan_mayu's avatar
        ryan_mayu
        Super User

        esingh 

        pls try this

         

        Measure = DIVIDE(sum('Table'[responseCount]), SUMX(FILTER('Table (2)','Table (2)'[institution_name]=MAX('Table'[institution_name])&& 'Table (2)'[optionString] in {"Indirect Costs","Direct Costs"} && 'Table (2)'[headerString] in {"aa","bb"}),'Table (2)'[responseCount]))
         
         
        pls see the attachment below