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
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
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.