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
Anonymous
Not applicable

Line chart using weighted survey data

Really new to Power BI -- apologies if this is a stupid question.

I have data as below. 

 

sampling weightcategoryyear

0.8

a1
1b2
1.2a3
0.7b1
1a2
1.3b3
0.9a1
1b2
1.9a3

 

I want to create a line chart showing the percent (accounting for the sampling weights) in each category over time. I have been able to get the output I want as a matrix by putting year as column, category as row, and sampling weight as values. But I can't figure out how to turn this into a line chart.

I have tried creating the following measures:

weightsum=sum('table'[sampling weight])

catsum=calculate([weightsum]), allexcept('table', 'table'[category])

pccat=divide([weightsum], [catsum], 0)

and using year for axis, category for legend, and catsum for values. But this gives me lines with each point being a percentage of the grand total and not for each year. I'm guessing I need to put the year into one or more of the measures I calculated (weightsum, catsum, pccat) but I'm not sure how. 

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You may try to modify your catsum measure if you want to calculate a percentage of each year.

catsum = calculate([weightsum],ALLEXCEPT('Table','Table'[year]))

111.png

 

You can check more details from here.

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You may try to modify your catsum measure if you want to calculate a percentage of each year.

catsum = calculate([weightsum],ALLEXCEPT('Table','Table'[year]))

111.png

 

You can check more details from here.

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , Not clear to me. refer if this can help

weightsum=sum('table'[sampling weight])
catsum=calculate([weightsum], all('table', 'table'[category]))
pccat=divide([weightsum], [catsum], 0)

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.