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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Dynamic Calculation based on filtering

Hello,

 

New to power bi, I need Power Bi to recalculate percentages based on the filters of a visualization.

 

I need to divide the Planned hours by actual hours to get an efficiency %, and then to be able to recalculate by whatever filter I choose i.e company, location, or week. Right now it is currently summing all planned hours and actual hours regardless of the filter.

 

data

soconner_1-1602786585878.jpeg

an attempt at the formula:

 

 

 

 

Efficiency = CALCULATE(sum(table[planned hours)/sum(table[actual hours]),ALLSELECTED(table))

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous 

 

You cannot divide in the calculate function, try separate the expression like the following:

Efficiency = CALCULATE(sum(table[planned hours),ALLSELECTED(table)) / CALCULATE(sum(table[actual hours]),ALLSELECTED(table))

 

Paul Zheng _ Community Support Team
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
Anonymous
Not applicable

@Anonymous 

 

You cannot divide in the calculate function, try separate the expression like the following:

Efficiency = CALCULATE(sum(table[planned hours),ALLSELECTED(table)) / CALCULATE(sum(table[actual hours]),ALLSELECTED(table))

 

Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

edhans
Super User
Super User

I'm not clear on why you are using ALLSELECTED. You are telling it to remove the filters from the table internally but keep filters from the outside. That means every row will be the same for whatever slicers/filters/crosshighlighting happens, but the filter context within the filter (company rows) is ignored. Just use this.

 

Effeciency = 
    DIVIDE(
        SUM('Table'[Planned]),
        SUM('Table'[Actual])
    )

You would only want some sort of ALL/REMOVEFILTERS if you needed the denominator for example, to remain constant no matter what, and then you use it on the denominator only. You've effectively used it on both numerator and denominator.

 

If you need more help, please post some data we can use (links below) and your expected results. Screenshots from Excel are good for expected result mock ups, but not for providing data for us to use.

 

How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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