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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
rcb0325
Helper I
Helper I

How to change the sum for a specific row when an IF statement wont work??

I have a table that is all summing correctly, but for the [WarehouseName] column, I want to change the calculation for [Total OnHand] to exclude certain "Planner Codes", but keep the current calculation for the other warehouses. My issue is the relationship between the two tables. I am unable to tell it
= IF( [WarehouseName] = "UNION WAREHOUSE", [Union Machine OnHand], [Total OnHand] )

The current calculation for the [Total OnHand] measure is :

 [Total OnHand] = CALCULATE( SUM('PROD fact InventorySummaryView'[OnHandPhysicalTons]), ALL('PROD dim PostedDateView'[PostedDateActualDate]) )

And I need to change the calculation only the "UNION WAREHOUSE" row to:
[Union Machine OnHand] = CALCULATE( SUM('PROD fact InventorySummaryView'[OnHandPhysicalTons]), ALL('PROD dim PostedDateView'[PostedDateActualDate]),
            FILTER( 'PROD dim InventoryDimensionView', 'PROD dim InventoryDimensionView'[WarehouseName] = "UNION WAREHOUSE"),
            FILTER( 'PROD dim ItemView', 'PROD dim ItemView'[PlannerCode] = "36M" ||
                    'PROD dim ItemView'[PlannerCode] = "37M" ||
                    'PROD dim ItemView'[PlannerCode] = "38M" ||
                    'PROD dim ItemView'[PlannerCode] = "39M" ||
                    'PROD dim ItemView'[PlannerCode] = "96M" )

These two measures by themselves work separately, but I am trying to combine them into one measure. 

Thanks in advance! 

rcb0325_0-1694109214723.png

 

2 REPLIES 2
amitchandak
Super User
Super User

@rcb0325 , a measure like

IF( max([WarehouseName]) = "UNION WAREHOUSE", [Union Machine OnHand], [Total OnHand] )

 

example of such calculation

Power BI How to get the P&L formatting right: https://youtu.be/C9K8uVfthUU

That did work! However the measure total is not summing correctly. Any suggestions? Thanks! 

rcb0325_0-1694453397050.png

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.