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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
pbrainard
Helper III
Helper III

Percent filter question

I'm calculating occupancy for a particular fiscal year, which seems to be working fine (except the total, I'd like that to be the average percentage of the total - right now it's summing).

 

The issue I run into is when I select multiple fiscal years. It's adding the percentages. How can I write this formula to give me a percentage over one or more fiscal years. I am using a date table.

 

Occupancy = DIVIDE([cntType], [psbBednights],0)

 

 

 

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

Hi, @pbrainard 

 

Try to add two additional measures, one to calculate the percentage of each year, and the other to modify the sum of the total to the average.

Sample data:

vangzhengmsft_0-1628674014599.png

_divide:

_divide = 
var _a=SUM('Table'[Sale])
var _b=CALCULATE(SUM('Table'[Sale]),ALL('Table'))
var _divide=DIVIDE(_a,_b)
return _divide

So to create 2 measures like this:

_Year% = CALCULATE([_divide],ALLEXCEPT('Table','Table'[Year]))

The result we want would be this:

_average% =
IF ( HASONEVALUE ( 'Table'[Year] ), [_divide], AVERAGEX ( 'Table', [_Year%] ) )

 result:

vangzhengmsft_2-1628674382337.png

 

Please refer to the attachment below for details

 

 

Hope this helps.

 

Best Regards,
Community Support Team _ Zeon Zheng
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-angzheng-msft
Community Support
Community Support

Hi, @pbrainard 

 

Try to add two additional measures, one to calculate the percentage of each year, and the other to modify the sum of the total to the average.

Sample data:

vangzhengmsft_0-1628674014599.png

_divide:

_divide = 
var _a=SUM('Table'[Sale])
var _b=CALCULATE(SUM('Table'[Sale]),ALL('Table'))
var _divide=DIVIDE(_a,_b)
return _divide

So to create 2 measures like this:

_Year% = CALCULATE([_divide],ALLEXCEPT('Table','Table'[Year]))

The result we want would be this:

_average% =
IF ( HASONEVALUE ( 'Table'[Year] ), [_divide], AVERAGEX ( 'Table', [_Year%] ) )

 result:

vangzhengmsft_2-1628674382337.png

 

Please refer to the attachment below for details

 

 

Hope this helps.

 

Best Regards,
Community Support Team _ Zeon Zheng
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

@pbrainard , this should work fine as long as these are sum or count measure

example

divide(sum(Table[A]), sum(Table[B]))

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.