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
isha_pote
Regular Visitor

How to calculate % of a count of a column?

Powerbi.PNG

I'm trying to calculate the % of waste distribution type for every month year so for example in the above image, I want a measure to calculate the % of every month so it should be like for Jan 2021 the % of Closed loop recycling =( 7/(7+15+24))*100 and same for landfill and open loop recycling. I want to display the % of waste distribution in a line chart against the date to get a trend of how much is he % of waste distrbution for every type in every month and year.

How do I create a measure for this?

1 ACCEPTED SOLUTION
WinterMist
Impactful Individual
Impactful Individual

I did not have access to your dataset, so I simply created a table based on your screenshot from the original post.

 

In my case, [Count of Waste Distribution Type] is actually a column in the table.

But you don't have this column, which is the reason for the error.

 

In your case, it's the measure.

Try replacing the SUM clause with your measure as follows:

 

CALCULATE(

   [Count of Waste distribution type],

   ALL('Waste data (3)'),

   'Calendar'[Date] = GivenDate

)

 

WinterMist_0-1679940706036.png

 

If it's still not working, perhaps you can share the PBIX on Google Drive and share the link here.

 

Regards,

Nathan

View solution in original post

7 REPLIES 7
isha_pote
Regular Visitor

I created the % measure and it worked. Thank you so much 🙂 I had been stuck on this for more than 2 weeks. Thank you 🙂

isha_pote
Regular Visitor

The new replaced SUM clause worked for me. Can you give me the new % measure as well?

WinterMist
Impactful Individual
Impactful Individual

I did not have access to your dataset, so I simply created a table based on your screenshot from the original post.

 

In my case, [Count of Waste Distribution Type] is actually a column in the table.

But you don't have this column, which is the reason for the error.

 

In your case, it's the measure.

Try replacing the SUM clause with your measure as follows:

 

CALCULATE(

   [Count of Waste distribution type],

   ALL('Waste data (3)'),

   'Calendar'[Date] = GivenDate

)

 

WinterMist_0-1679940706036.png

 

If it's still not working, perhaps you can share the PBIX on Google Drive and share the link here.

 

Regards,

Nathan

isha_pote
Regular Visitor

5.PNG6.PNG

 

I tried the formula you have provided and I'm getting an error in the Count of waste distribution type in the 1st image as you can see. I've added the screenshot for the count of waste distribution type measure which I have created. Could you please help with what's going wrong?

isha_pote
Regular Visitor

pbi2.PNG

pbi3.PNG

I used the above formula to calculate month total and it's not giving the correct inforation and when I bring it to the visualisation it's not displaying any info.

@isha_pote 

 

Whenever this happens to me, it's helpful to separate each VAR (and the RETURN section) into its own measure to isolate smaller pieces of code.

 

If the at-fault piece of code is a CALCULATE statement, try changing it a bit to see if the issue is with the FILTER section or something else.  In this way, you should be able to identify the exact line of code that's causing the problem.

 

Once you can pinpoint which piece of code is causing the visual to break, then you need to click "See Details" to see what the error message is.

 

Regards,

Nathan

WinterMist
Impactful Individual
Impactful Individual

@isha_pote 

 

I separated this into 2 measures so you can see the results, but feel free to combine them.

 

WinterMist_0-1679604859767.png

WinterMist_1-1679604895522.png

 

WinterMist_2-1679604970730.png

 

Hopefully this is helpful to you.

 

Regards,

Nathan

 

 

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.

Top Solution Authors