Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

SUM UP Min Measure

Hello experts, 
I have this data table. I want to return MIN of Lost Sales, SOH and SIT
- If the earliest StockAvailDate is before end of current month => incluce SIT 
- If the earliest StockAvailDate is after end of current month => excluce SIT  

ITEM_DESCLost Sales Qty (Net)DC SOHSITEarliest StockAvailDate
GENTLE EYE MU REMOVER 100ML/3.4FLOZ300141011/19/2023 0:00
GENTLE EYE MU REMOVER 100ML/3.4FLOZ150141011/19/2023 0:00
DW SIP MU SPF 10-PEBBLE 30ML/1FLOZ3138512/8/2023 0:00
DW SIP MU SPF 10-SHELL B 30ML/1FLOZ50  
CRM - ULRY TL 200ML379  
CRM - BFUL MAG 50ML2217  
SPRM+ BRT PWR SFT CRM RF 75ML/2.5OZ30812/6/2023 0:00
SPRM+ BRT PWR SFT CRM RF 75ML/2.5OZ30912/6/2023 0:00

My measure:
Recover = 
VAR SI_date = CALCULATE( sum ('Fact - SIT'[SIT Qty]), filter ( all ('Fact - SIT'[StockAvailDate]), 'Fact - SIT'[StockAvailDate] < EOMONTH( today () ,0 )))

VAR DCSOH =
IF (
    CALCULATE ( SUM ( 'Fact - 5810 SOH'[DC Stock] ) ) = BLANK (),
    0,
    CALCULATE ( SUM ( 'Fact - 5810 SOH'[DC Stock]) )
)
VAR temp = { [Lost Sales Qty (Net)], DCSOH, SI_date }
RETURN
     MINX ( Temp, [Value] )

Here is Measure return: 

ITEM_DESCLost Sales Qty (Net)DC SOHSITEarliest StockAvailDateQty SI
GENTLE EYE MU REMOVER 100ML/3.4FLOZ300141011/19/2023 0:000
GENTLE EYE MU REMOVER 100ML/3.4FLOZ150141011/19/2023 0:000
DW SIP MU SPF 10-PEBBLE 30ML/1FLOZ3138512/8/2023 0:003
DW SIP MU SPF 10-SHELL B 30ML/1FLOZ50  0
CRM - ULRY TL 200ML379  3
CRM - BFUL MAG 50ML2217  2
SPRM+ BRT PWR SFT CRM RF 75ML/2.5OZ30812/6/2023 0:000
SPRM+ BRT PWR SFT CRM RF 75ML/2.5OZ30912/6/2023 0:000
Total64   64

  • My question:
    1. Why first 2 lines return to 0? I want it return to 30 & 15 as SIT colum = 1410 and available date is still less than 30 Nov
    2. Sum colum Qty SI return to the min of 3 colums. How can i sum those based on the Qty SI colum. 
    Out come i would like to achive:
  •  
ITEM_DESCLost Sales Qty (Net)DC SOHSITEarliest StockAvailDateQty SI
GENTLE EYE MU REMOVER 100ML/3.4FLOZ300141011/19/2023 0:0030
GENTLE EYE MU REMOVER 100ML/3.4FLOZ150141011/19/2023 0:0015
DW SIP MU SPF 10-PEBBLE 30ML/1FLOZ3138512/8/2023 0:003
DW SIP MU SPF 10-SHELL B 30ML/1FLOZ50  0
CRM - ULRY TL 200ML379  3
CRM - BFUL MAG 50ML2217  2
SPRM+ BRT PWR SFT CRM RF 75ML/2.5OZ30812/6/2023 0:000
SPRM+ BRT PWR SFT CRM RF 75ML/2.5OZ30912/6/2023 0:000
Total64   53

  • TIA 🙏

2 Replies

  • 1.Why 0 ?

    I think the issue with the first two lines returning 0 is because the calculation of Si_date is not filtering the 'Fact - SIT' table by individual 'ITEM_DESC' and 'StockAvailDate' conditions. To resolve this, you need to adjust the calculation to filter the 'Fact - SIT' table based on the corresponding 'ITEM_DESC' and 'StockAvailDate' conditions for each item individually.

    • Anonymous's avatar
      Anonymous
      Not applicable

      🤔i dont get this "the corresponding 'ITEM_DESC' and 'StockAvailDate' conditions for each item individually" can you please give me some advise?