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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
sur27078
Regular Visitor

New measure filter by cost center and month

Hi,

I am new with this Var command and I am trying to do % calculation from Single column. I have the following New measure but it seems calculate all number. How can I filter based on Cost_Center and Month when I splice in table?

 

The result should be 0.42 which translate to 42% ( Total sum of rc and projected cost divided by rc)

 

Gross Margin % =
VAR _TotalRevenue = CALCULATE( SUM( 'GL_Balance_MC (2)'[ReverseBalance]), FILTER( ALL( 'GL_Balance_MC (2)' ), [Code] IN { "rc" } ) )
VAR _GrossMargin = CALCULATE( SUM( 'GL_Balance_MC (2)'[ReverseBalance] ), FILTER( ALL( 'GL_Balance_MC (2)' ), [Code] IN { "rc", "projectcost" } ) )
VAR _Return = DIVIDE( _GrossMargin, _TotalRevenue, 0 )
RETURN _Return
sur27078_0-1757967918862.pngsur27078_1-1757968076247.png

 

 

Thanks
Sur
1 ACCEPTED SOLUTION
sur27078
Regular Visitor

@Irwan Thank you. I just realized that. I changed to "ALLSELECTED" and it seems working. 

View solution in original post

3 REPLIES 3
sur27078
Regular Visitor

@Irwan Thank you. I just realized that. I changed to "ALLSELECTED" and it seems working. 

Hi @sur27078,

Thank you for the update. Glad to hear that ALLSELECTED worked for you. If you encounter any other issues or need more clarification, feel free to reach out. We're here to assist.

 

Thank you.

Irwan
Super User
Super User

hello @sur27078 

 

it seems because of ALL function.

Irwan_1-1757975574996.png

 

here is a simple example.

Irwan_0-1757975538911.png

measure with ALL inside FILTER will have same value.

measure without ALL inside FILTER will have vary result because the value will depend on applied filter.

 

Hope this will help.

Thank you.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.