Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Check based on Group of items

Hi everyone, 

Another tricky problem here. I need to add a column in my Sales Detail table that will tell me whether or not the Family of that particular item had its '01' Velocity Code out of stock (specifically, when that item number appeared in the Out of Stock Detail table on the same date). There are many item numbers per Family, and each item may have different velocity codes and may not be out of stock at the same time. 

 

Any help with this would be great. Relevant Table information below:

 

New column Required: FAMILY OOS STATUS, which would return a simply Y/N flag whether the conditions listed above are met. 

 

Sales Detail

Columns: Item Number, Date, FAMILY OOS STATUS

 

Out of Stock Detail (item number is populated with the day it was out of stock, when it is in stock rows will not be added)

Columns: Item Number, OOS Date

 

Item Master

Columns: Item Number, Family Code, Velocity Code ('01', '02', '03', or '99')

6 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for the quick reply, see below. 

       

      EXAMPLE

      Item NumberDateFamily OOS StatusLiteral question / answer
      529-Mar-20NWas an item in Family 2 with Velocity Code 1 in stock?
      Items 4 does not appear in OOS detail on that date, therefore was in stock and was not orered, flag should be reflected as 'N'. 
      825-Mar-20YWas an item in Family 2 with Velocity Code 1 in stock?
      Item 8 is a Velocity Code 1, and Items 8,9,14 does not appear in OOS detail on that date, therefore was in stock and was orered, flag should be reflected as 'Y'. 

       

       

      Sales Detail

      Item NumberDateFamily OOS Status
      529-Mar-20N
      825-Mar-20Y
      826-Mar-20Y
      829-Mar-20Y
      925-Mar-20Y
      926-Mar-20Y
      929-Mar-20Y
      1026-Mar-20N
      1028-Mar-20N
      1125-Mar-20N
      1126-Mar-20N
      1129-Mar-20N
      1425-Mar-20Y
      1426-Mar-20Y
      1429-Mar-20Y

       

      OOS Detail

      Item NumberOOS Date
      225-Mar-20
      625-Mar-20
      1025-Mar-20
      1029-Mar-20
      1226-Mar-20
      1228-Mar-20
      1229-Mar-20
      1325-Mar-20
      1326-Mar-20
      1328-Mar-20
      1329-Mar-20
      1525-Mar-20
      1526-Mar-20
      1528-Mar-20
      1529-Mar-20

       

       

      Item Master

      Item NumberFamilyVelocity Code
      2199
      313
      411
      512
      6199
      712
      821
      921
      1022
      1122
      1222
      1321
      1421
      1522
      • v-gizhi-msft's avatar
        v-gizhi-msft
        Icon for Community Support rankCommunity Support

        Hi,

         

        According to your description, please try this measure:

        Measure = 
        VAR family =
            CALCULATETABLE (
                DISTINCT ( 'Item Master'[Family] ),
                FILTER (
                    ALLSELECTED ( 'Item Master' ),
                    'Item Master'[Item Number] IN DISTINCT ( 'Sales Detail'[Item Number] )
                )
            )
        VAR items =
            CALCULATETABLE (
                DISTINCT ( 'Item Master'[Item Number] ),
                FILTER (
                    ALLSELECTED ( 'Item Master' ),
                    'Item Master'[Family] IN family
                        && 'Item Master'[Velocity Code] = 1
                )
            )
        RETURN
            IF (
                CALCULATE (
                    COUNTROWS ( 'OOS Detail' ),
                    FILTER (
                        ALLSELECTED ( 'OOS Detail' ),
                        'OOS Detail'[Item Number] IN items
                            && 'OOS Detail'[OOS Date] IN DISTINCT ( 'Sales Detail'[Date] )
                    )
                ) > 0,
                "Y",
                "N"
            )

        And i think according to the logic you explained, my test result is a little different from your expected result, please check it.

        My test result shows:

        Here is my test pbix file:

        pbix 

        Hope this helps.

         

        Best Regards,

        Giotto