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
swaggerboy69
Helper IV
Helper IV

Percentage not Correctly Showing when filtered by country

Hello Team,

 

This is with regards to the topic - https://community.powerbi.com/t5/Desktop/Calculate-Monthly-Growth-that-would-respond-to-slicers-for/...

 

It worked before but after a month when I try to filter by country, it doesn't show correct values anymore.

 

See below if not filtered:

swaggerboy69_3-1655741129066.png

 

When filtered by a specific country:

swaggerboy69_2-1655741111023.png

See code being used below:

 

==============================================================================

Call Count PM =
VAR CurrentYearMonth = SELECTEDVALUE('Return to Office'[YearMonthNum])
VAR PreviousYearMonth =
CALCULATE(
MAX('Return to Office'[YearMonthNum]),
ALLSELECTED('Return to Office'),
KEEPFILTERS('Return to Office'[YearMonthNum] < CurrentYearMonth)
)
VAR Result =
CALCULATE(
[Internal Call Count No Blank],
'Return to Office'[YearMonthNum] = PreviousYearMonth,
REMOVEFILTERS('Return to Office')
)
RETURN
Result


==============================================================================

Call Count Diff PM =
VAR CallCountCurrentMonth = [Internal Call Count No Blank]
VAR CallCountPrevMonth = [Call Count PM]
VAR Result =
DIVIDE(
CallCountCurrentMonth - CallCountPrevMonth,
(NOT ISBLANK (CallCountCurrentMonth))*(NOT ISBLANK (CallCountPrevMonth))
)
RETURN
Result

==============================================================================

% Call Count Monthly Growth =
DIVIDE(
[Call Count Diff PM],
[Call Count PM]
)

==============================================================================

 

Let me know what I'm doing wrong.

1 ACCEPTED SOLUTION
swaggerboy69
Helper IV
Helper IV

I resolved the issue.

I added ALL ( 'Date' )

Then removed REMOVEFILTERS

View solution in original post

6 REPLIES 6
swaggerboy69
Helper IV
Helper IV

I resolved the issue.

I added ALL ( 'Date' )

Then removed REMOVEFILTERS

tamerj1
Super User
Super User

@swaggerboy69 

Advise you to have a date table. Code will be more simple and more efficient. 

Any code/logic suggestions?

@swaggerboy69 

Almost the same code that you are using now. Just there is no need to use ALLSELECTED as the date will be filtered using a separate table. Please provide more details about your data and its granularity then might be able to help you further

ok. so my data is counting call counts from a video conferencing device per month.

so i need to be able to see growth rate of calls per month.

it shows the correct percentage if not filtered by country. 

the issue shows up when i filter by country or city or office location.

Hi @swaggerboy69,

According to your description, it sounds like multiple aggregates calculate issues on DAX formulas.
For this scenario, you can try to add a variable with summarizing function to group the calculated result based on current category fields. Then you can use the iterator function sumx to apply the second aggregate to summary previous results:

Measure Totals, The Final Word 
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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