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
GE1
Frequent Visitor

Need to get a total but ALLSELECTED or ALLEXCEPT not working

Hi

 

I have some data in PowerBI that looks like this (this is much simplified):

GE1_0-1714084881693.png


The entries in yellow are duplicate population counts. There are two entries for this because both Brand 1 and Brand 2 cover the same town.

What I want to be able to do is have slicers that allow the user to select the brand, town etc and get the right results. I would then calculate % Population for whatever was selected.

I can get Power BI to calculate the population for each brand like this:
Brand Population = sumx(DISTINCT('Table'[Lookup]),FIRSTNONBLANK('Table'[Population],0))

...which looks for the first entry for Town1Date1 and ignores the rest. This gives Brand 1 = 30 and Brand 2 = 40. This works when brand or town filters are applied and gives the correct amount for each date.

But I cannot get it to work out the total monthly i.e. 10 + 12 = 22 (not 32) or grand total population i.e. 10 + 20 + 12 + 18 = 60 (not 70). I'd want something like:

Total Population =
CALCULATE(
sumx(DISTINCT('Table'[Lookup]),FIRSTNONBLANK('Table'[Population],0)),
ALLEXCEPT ('Table', 'Table'[Date]))

...so that it ignored the Brand and Town when adding up, giving a total for the month or overall, and I can calculate %s from that. But this does not work at all - it gives the same answer for each date. I also can't use ALLSELECTED because it doesn't work with sumx.

 

Thank you

1 REPLY 1
Ashish_Mathur
Super User
Super User

Hi,

Share some actual date entries in the Date column and for that dataset, show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.