Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

SumX for Product Value based on Max Date

I have a warehouse report that shows stock levels.

 

I have the following formula that is aiming to return 1 of 2 values:

If the [Reporting Date] is filtered then show the [product value] based on the [Reporting Date], else show the [product value] based on the most recent [Reporting Date].

 

 

WHS Value = 
VAR _ReportDate =
    MAX ( 'Table1'[Reporting Date] )

RETURN
    IF (
        ISFILTERED ( 'Table1'[Reporting Date] ) = FALSE (),
        SUMX (
            FILTER ( 'Table1', _ReportDate = 'Table 1'[Reporting Date] ),
            'Table1'[Product Value]
        ),
        SUM ( 'Table1'[Product Value] )
    )

 

 

My issue is that if there is no stock in the warehouse it's a null value, and the formula displayed is showing historic data from older snapshots.

How can I amend this formula so that where products have no stock (and the report is null) - it excludes them from the formula when no report date is selected?

 

 

7 Replies

  • Hi,

    Share some data (in a format that can be pasted in an MS Excel file), explain the question and show the expected result. in a simple Table format.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Ashish_Mathur below is a pivot table summary with the current result vs expected result. I've also included a raw example which can be pivoted.

       

      This is essentially an exercise in handling nulls/blanks where stock is not present at certain times.

       

       SOH  Current ResultExpected Result
      Product ID21/11/2022

      19/12/2022

      16/01/2023  
      100151221814 140
      1001577522 20
      100235673890  38900
      1002480644 40
      100248811  10
      100274914  40
      100021311313131313
      100021863034151515
      1000218999333
      100021901113141414
      100021952735181818
      100021961112131313

       

      Raw Extract:

      Product NumberUnit Of MeasureSOHReport Run Date
      10015122EA1821/11/2022
      10015775EA221/11/2022
      10023567MT89021/11/2022
      10023567MT200021/11/2022
      10023567MT100021/11/2022
      10024806EA421/11/2022
      10027491EA421/11/2022
      10002189EA321/11/2022
      10002189EA521/11/2022
      10002189EA121/11/2022
      10002190EA621/11/2022
      10002190EA221/11/2022
      10002190EA321/11/2022
      10015122EA1419/12/2022
      10015775EA219/12/2022
      10024806EA419/12/2022
      10002189EA419/12/2022
      10002189EA419/12/2022
      10002189EA119/12/2022
      10002190EA819/12/2022
      10002190EA319/12/2022
      10002190EA219/12/2022
      10002189EA216/01/2023
      10002189EA116/01/2023
      10002190EA816/01/2023
      10002190EA416/01/2023
      10002190EA216/01/2023