Forum Discussion

MyWeeLola's avatar
MyWeeLola
Icon for Helper II rankHelper II
1 year ago

Calculate between displayed tables

Good morning

I am looking for guidance and or a solution to a probelm I am having and I appreciate any help I can get.

 

I have 3 tables 

TableSubject is displayed on screen and has two columns as below. It has a row of subjects and the count of how many times they appear in a sliced time filter. This is derived from a pivoted table. The count of times gives me a weighting of importance to the user. The weighting will change based on viewer slicer selection.

 

The second table, TableCampaign, is a table which contains a list of campaigns and the subject(s) that they cover. It has a value under the subjects which determine the relevance of the subject. These values are fixed and will not change.

 

The third table is my desired result.

TableResult contains a list of the campaigns and a score. The score is derived from adding up all the values of the subjects in a row, multiplied by each weighting. For example Camp1 = Subject 1 * Subject 1 weighting + subject 4 * subject 4 weighting = (50*2)+(1*25) = 125

For TableResult I will sort the score largest to smallest.  This then tells me what campaigns are relevent to the current customer experience.

 

I have recreated the tables below.

While a complete solution would be really nice, I am looking for guidance on how to get the tables to relate so that i can do the calculations and what method i should use to ensure the culatulations refresh on use slicer selection.

 

I look forward to any guidance you can provide.

 

Lola

TableSubjectWeighting
Subject150
Subject240
Subject330
Subject425
Subject520
Subject615
Subject712
Subject810
Subject95
Subject101

 

TableCampaignSubject1Subject2Subject3Subject4Subject5Subject6Subject7Subject8Subject9Subject10
Camp12  1      
Camp2 2      1 
Camp3 2     2  
Camp41    2    
Camp5  2   1  1
Camp6 1  2   1 
Camp72   11    
Camp8   1    2 
Camp91    2   1
Camp10 111   2  

 

TableResultScore
Camp1125
Camp285
Camp3100
Camp480
Camp573
Camp680
Camp7135
Camp835
Camp980
Camp10105

5 Replies

  • Hi MyWeeLola ,

     

    For this you need to do the following:

    • Unpivot the campaing table so that you have the following setup

     

    • Do a relationship between the subject and the campaing:

     

    • Add the following measure:
    Weighted Value = 
            SUMX(
    			ADDCOLUMNS(
    				'Campaign',
    				"Weigt", RELATED(Subject[Weighting])
    			),
    			'Campaign'[Value] * [Weigt]
    		)
    
    

     

     

     

    Check PBIX file attach.

    • MyWeeLola's avatar
      MyWeeLola
      Icon for Helper II rankHelper II

      someone accepted this as the solution, but it did not fix the original problem. I went to an external resource to fix it as nothing anyone posted here resolved the issue. However i am appreciative of people trying to help.

       

      • MFelix's avatar
        MFelix
        Icon for Super User rankSuper User

        Hi MyWeeLola ,

         

        What is the problem, I apologize for missintreperting the question. Can you please elaborate on what is the question at hand.

         

        To what I can understand you want to have the calculation based on the weighted values, and the solution I gave you does that calculation.

         

        Is there any issue with the unpivot of the tables? What is not matching your needs?

         

        I see that the last values are not macthing the result you shared but I believe is because I copied the information incorrectly for line 10.

         

        I have also unmarked the answer to be correct since you refer that is not the solution (other user on the community can accept answers and probably that is what happened).

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,

    Based on the description, the method MFelix  provided should be helpful.

    Please view the method, if the method helps, please consider Accept it as the solution to help the other members find it more quickly.

     

    Best Regards,

    Wisdom Wu