Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
danieldefo
Frequent Visitor

weighted average for survey result

Hi all,

I would really appreciate your help with the following.

I have some figures as in the following excel example.

The figure in this screenshot it is just count of respondent answers for spesific question with different evalution rate(1,2,3,4,5)

what I need to find Weighted Average for different question category,in excel it is easy to calculated using by SUMPRODUCT(example calculation for Quality survey question(1x3+13x2+3x24+4x4+5x1)/number of respondents(45 pers)=2.7

but with DAX it seems to me more complicated 

Would be so nice to hearing by your side.

 

 

Weighted Average Calculation.PNG

1 ACCEPTED SOLUTION

Hi,

 

In the column area section of the visual, drag the Value field from the reporting PulseCheckSurvey table.  In the file that you shared with me over a private message, this formula work perfectly

 

=IF(HASONEVALUE('reporting PulseCheckSurvey'[Value]),[Number of Respondents],SUMX(SUMMARIZE(VALUES('reporting PulseCheckSurvey'[Value]),[Value],"ABCD",MIN('reporting PulseCheckSurvey'[Value]),"EFGH",[Number of Respondents]),([ABCD]*[EFGH]))/[Number of Respondents])

 

Hope this helps.

 

Untitled.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

9 REPLIES 9
BR-MSBI
New Member

Hi Ashish, 

Hope you are well! I have a build on this thread and have data from different question types (binary - yes/ no, Likert - 7pt and 9pt scales, location close coded responses - choose which country & city etc.) So while I can work out the unweighted averages, the formula above does not work if I want to create a measure for weighted data for every column, how would you suggest to do that? 

I have attached an excerpt of the data sheet. 

Thanks in advance! 

UNIQUE FILE NAME CountryTesting Location # Question #
(L7/L10)
Test BrandAssigned CellParticipant IDDateLanguageUser Type
(Core vs. Prospect)
First Like Score (L1)Second Like Score (L2)Satisfaction Score (N12)Lemon-Lime / OrangeDiet / RegularSweetness LevelCarbonation Level
143I9187D10665EOKenyaNairobi - SaritL7Brand AC28398635382022-02-03EnglishCore876Orange RegularNot mentionedYes
348O4243X87055CUKenyaNairobi - SaritL7Brand AC29550214622022-02-03EnglishCore999Lemon-LimeRegularSweetYes
199Y4413B73708FTChina Shanghai L7Brand BC56820797602022-02-03EnglishCore8910Lemon-LimeDiet SweetYes
570L1507V48639ONKenyaNairobi - SaritL7Brand AF22751064172022-02-03EnglishCore8811Lemon-LimeRegularJust rightNot mentioned
504R8276M53107AFKenyaNairobi - SaritL7Brand AF26289492762022-02-03EnglishCore889Orange RegularToo sweetYes
746O2369I70887CUChina Beijing L7Brand BF87427921052022-02-03EnglishProspect9911Lemon-LimeRegularSweetNot mentioned
448K6964P62186RVKenyaNairobi - SaritL7Brand AFP57784567332022-02-03EnglishCore9910Lemon-LimeDiet SweetYes
768X7665Q71962OFKenyaNairobi - SaritL7Brand AFP58311857742022-02-03EnglishCore9911Orange RegularSweetNot mentioned
492A5083R30542RCKenyaNairobi - SaritL7Brand BFP86604495322022-02-03EnglishCore889Lemon-LimeRegularSweetNot mentioned
293A2047V54660BJKenyaNairobi - SaritL7Brand BFP72648140692022-02-03EnglishProspect679Orange Regular  
312X8609N27744TQAustralia Melbourne L10Brand AC10850297252022-02-03EnglishCore689Lemon-LimeRegular  
241E8133H99505FUAustraia Sydney L7Brand AC91631023932022-02-03EnglishCore7910Lemon-LimeRegularNot too sweetNo
893A4354I83561QGKenyaNairobi - RioL7Brand BFP39468267792022-02-03EnglishCore9911Orange Diet Not mentionedYes
903R4639E91919HFIndia Lucknow L10Brand AFP61688571192022-02-03Hindi Core8911Lemon-LimeRegularJust rightNot mentioned
717J9486U70243CIIndia Lucknow L7Brand BC56034855772022-02-04Hindi Core9911Orange RegularJust rightNo

Hi,

I cannot understand your question.  In a Table form, show the exact result you are expecting.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish, Apologies for not being clear about the ask. While I can't share the complete data file as it has 50K records, it is sensitive and have appended other queries to the core table, I will try and elaborate a bit more on the table above. 

If we take the first liked score column, this was a question asked of the respondents to rate thier first sip on a 9 point scale (e.g. on a scale of 1-9 how would you rate your first sip?) the values that you are seeing are the score each respondent gave for the first sip. So I have calculated the total sample (base Size) using COUNTROWS DAX in the first column Unique file name and then calculated unweighted % using the DAX = DIVIDE([BaseSize], CALCULATE([BaseSize],ALL(Sheet1)))*100 (Sheet1 is the excerpt I shared earlier). So I have calculated unweighted data % but what I am struggling with is to calculate weighted %. In other words, what is the weighted % of the testing location (which is text based) or what is the weighted % of first liked score or second liked score etc. 

Is there a way to calculate the weighted data for all the columns? 

Hope that makes sense! I am happy to do a screen share and show you what I am working with on a video call but fully understand if you don't want to do that. 

Thanks in advance for your help 

Bala

Based on the data that you shared, show the expected result very clearly.  It will be ideal if you can share the download link of an MS Excel file with 2 tabs - input data and expected result.  


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

 

This is not difficult in DAX.  One has to use the SUMX() function.  Share your dataset.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

HI, please this is my dataset, in my calculation for number of candidates  in second picutre, I have  used distincount

 

dataset.PNGdataset2.PNG

Hi,

 

Not very sure but try this

 

=IF(HASONEVALUE(Data[Value]),your_measure,SUMX(SUMMARIZE(VALUES(Data[Value]),[Value],"ABCD",MIN(Data[Value]),"EFGH",your_measure,"IJKL",[ABCD]*[EFGH]),[IJKL]/your_measure))

 

If this does not work, then share the link from where i can download your file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

 

In the column area section of the visual, drag the Value field from the reporting PulseCheckSurvey table.  In the file that you shared with me over a private message, this formula work perfectly

 

=IF(HASONEVALUE('reporting PulseCheckSurvey'[Value]),[Number of Respondents],SUMX(SUMMARIZE(VALUES('reporting PulseCheckSurvey'[Value]),[Value],"ABCD",MIN('reporting PulseCheckSurvey'[Value]),"EFGH",[Number of Respondents]),([ABCD]*[EFGH]))/[Number of Respondents])

 

Hope this helps.

 

Untitled.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Dear Mathur,

 

Thanks for your help.It works perfectly

 

Have a nice fruitful day

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.