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
esuing
Helper I
Helper I

Problems using the ALL() function

I feel like this is a simple case, but I don't know what's happening. I have the following tables:

 

ColorTypes:

esuing_0-1666815907771.png

Types:

esuing_1-1666815940560.png

Data:

esuing_2-1666815969069.png

The joins should be pretty obvious (Data[Color] -> ColorTypes[Color], etc). And then I put together a very simple table that sums the Amt field by type and color:

esuing_3-1666816011159.png

I would like to add a measure that is the sum of the Amt for each type regardless of Color.  I use this function with this result:

Type Total = CALCULATE([Sum Amt],All(Data[Color]))
esuing_4-1666816227447.png

 

It should look something like this:

esuing_5-1666816369703.png

I'm not sure why it's introducing those new records as it doesn't seem to be adhering to the relationships between the three tables. Any help would be appreciated.

 

Thanks!

Eric

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @esuing,

It seems like the expression also expands the category groups which do not include records. Perhaps you can add an if statement to your expression to skip the calculation on these blank parts.

Type Total =
VAR result =
    CALCULATE ( [Sum Amt], ALL ( Data[Color] ) )
RETURN
    IF ( [Sum Amt] > 0, result )

Regards,

Xiaoxin Sheng

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

HI @esuing,

It seems like the expression also expands the category groups which do not include records. Perhaps you can add an if statement to your expression to skip the calculation on these blank parts.

Type Total =
VAR result =
    CALCULATE ( [Sum Amt], ALL ( Data[Color] ) )
RETURN
    IF ( [Sum Amt] > 0, result )

Regards,

Xiaoxin Sheng

Thank you! This is what I was looking for any worked in my other application with a much larger dataset really well!

Mikelytics
Resident Rockstar
Resident Rockstar

Hi Eric,

 

Please try: 

Type Total = CALCULATE([Sum Amt],All(ColorTypes[Color])) and when you put the columns in the visual please use the color column from the ColorTypes table

 

Best regards

Michael

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!
aj1973
Community Champion
Community Champion

Hi @esuing 

Go to filter Panel 

aj1973_0-1666819052762.png

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Hi. Thanks.. this does work, however, I was hoping there was something in the measure itself that would prevent me from having to do this as it seems it would run more efficiently if it didn't return a value for every value in both tables..  The dataset I'm using for work is HUGE (versus this example I just presented in this thread) and so it's very slow doing it this way.

aj1973
Community Champion
Community Champion

Use the same columns from the Table ColorTypes into your visual and modify the measure:

aj1973_0-1666820431076.png

 

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

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 community update carousel

Fabric Community Update - June 2025

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