简体   繁体   中英

Power BI Dax measure not summing correctly for conditional formatting

I am attempting to add conditional formatting to a column in a table in a Power Bi report - this is values based to alert the team with a quick glance if something is low or close to being out of stock so they can reorder before that happens.

First, I have a measure to sum my quantities.

Quantity Sum = CALCULATE(SUM('FIN IC_BIN_DETAIL_STATUS'[Quantity]),'FIN IC_BIN_DETAIL_STATUS'[Part Code])

Second, I have a column created using a switch formula:

OOS Column = SWITCH( TRUE(), 'FIN IC_BIN_DETAIL_STATUS'[Part Code] ="500107" && [Quantity Sum] >= 401, "Green", 'FIN IC_BIN_DETAIL_STATUS'[Part Code] ="500107" && [Quantity Sum] >= 201, "Yellow", 'FIN IC_BIN_DETAIL_STATUS'[Part Code] ="500107" && [Quantity Sum] <= 200, "Red", 'FIN IC_BIN_DETAIL_STATUS'[Part Code] ="500108" && [Quantity Sum] >= 151, "Green", 'FIN IC_BIN_DETAIL_STATUS'[Part Code] ="500108" && [Quantity Sum] >= 51, "Yellow", 'FIN IC_BIN_DETAIL_STATUS'[Part Code] ="500108" && [Quantity Sum] <= 50, "Red", 'FIN IC_BIN_DETAIL_STATUS'[Part Code] ="500233" && [Quantity Sum] >= 151, "Green", 'FIN IC_BIN_DETAIL_STATUS'[Part Code] ="500233" && [Quantity Sum] >= 51, "Yellow", 'FIN IC_BIN_DETAIL_STATUS'[Part Code] ="500233" && [Quantity Sum] <= 50, "Red", "Blue")

And third I have another measure to assign a value to the color codes to allow for conditional formatting.

OOS Measure = SWITCH(MAX('FIN IC_BIN_DETAIL_STATUS'[OOS Column]),"Red",1,"Yellow",2,"Green",3,"Blue",4,5)

My problem is the 'FIN IC_BIN_DETAIL_STATUS' table has locations and when I apply the conditional formatting, the colors are wrong. The measure seems to be summing each location individually instead of the part code in whole, so the colors are incorrect unless the values I am looking for are correct in the individual locations. Is there a way to get the sum to look at everything and ignore the locations? Every table I can look at for this information theoretically will have the same issue because they are all location based.

Try using

Quantity Sum = CALCULATE(SUM('FIN IC_BIN_DETAIL_STATUS'[Quantity]),ALL('FIN IC_BIN_DETAIL_STATUS'[Part Code]))

for your measure.

This should ignore the location filtering on the Part Code in your table visuals.

Try this one:(Ignore the filter on location column)

Your_Measure =
CALCULATE (
    SUM ( 'FIN IC_BIN_DETAIL_STATUS'[Quantity] ),
    ALL('FIN IC_BIN_DETAIL_STATUS'[location] )
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM