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
charlyrosero
Frequent Visitor

Join Columns with Rows

Hi

 

the main idea it's show the Total Weight  by question in a survey. the survey  table there are ID questions  (columns) with values 1 (means the participant answered Yes) and 0 (means that the participat answered No). for the other hand the table weitghtQuestion with the fields idquestion, weight. the point it's that the last table save the values in rows.

 

Survey Table

idParticipantQuestion_1Question_2Question_3Question_4
11100
20101
31011
40101

 

Weight Question Table

idQUestionWeight
Question_110
Question_25
Question_315
Question_420

 

Result

 

QuestionTotal Weight 
Question_120(10 + 10)
Question_215(5 + 5 + 5)
Question_315(15)
Question_460(20 + 20 + 20)

 

 

thank you s much for the help

 

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


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

View solution in original post

7 REPLIES 7
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


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

Hi @Ashish_Mathur , @Nathaniel_C  Thank you so much. your help was very useful. 

 

@Ashish_Mathur this solution lets to work with any questions and any weight questions. 

You are welcome.


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

Hi @charlyrosero ,

Try this: will post the pbix in a couple.weighted.PNG

 

 

 

 

Total Weight = 
var _Q1 = Sum(Survey[Question_1] ) * MAX('Weight'[Question_1])
var _Q2 = Sum(Survey[Question_2] ) * MAX('Weight'[Question_2])
var _Q3 = Sum(Survey[Question_3] ) * MAX('Weight'[Question_3])
var _Q4 = Sum(Survey[Question_4] ) * MAX('Weight'[Question_4])

var _Sw = SWITCH(TRUE(),
           MAX(Weights[IdQUestion]) = "Question_1", _Q1,
           MAX(Weights[IdQUestion]) = "Question_2", _Q2,
           MAX(Weights[IdQUestion]) = "Question_3", _Q3,
           MAX(Weights[IdQUestion]) = "Question_4", _Q4)


return _Sw


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @charlyrosero ,

PBIXWeighted Survey

 

I used both your tables, but the weighted table I created a copy and transposed it so we could get MAX for each value. Let me know if you need to know anything about transposing and duplicating in Power Query.


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi  @Nathaniel_C !
thank you. great solution. I only have one question. there are 80 questions and 80 weights. is there  a dynamic solution for do not create each one measure?

Hi @charlyrosero ,

Let me think about that.  I just did the first line, and copied and pasted the rest. Then changed the numbers.  It was pretty quick.

 


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.