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
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
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.