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
Anonymous
Not applicable

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 6
Greg_Deckler
Super User
Super User

Sample data would be great. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
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

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:

15.PNG

Here is my test pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto

Anonymous
Not applicable

I think I see where part of the unexpected results could be coming from. In my production data, there could be many items with Velocity Code '01' and if any of those Velocity Code '01' items are available in the same family (not in the OOS Detail table) then I would consier that Family to have it's Velocity Code '01' on stock and should be producing an 'N' at the end result. 

Hi,

 

According to your further explaination, i am still confused about your expected result on Item10 and 11.

Could you please explain more about why Item10 and 11 expected result are N and Item 14 is Y?

This will let me to help you further.

Expect your reply!

Thanks!

 

Best Regards,

Giotto

Anonymous
Not applicable

I think your work is definately getting my closer to my goal, I'll just have to confirm the data and tweak where necessary. 

Adding this as a calculated column seems to work great, but when I tried to add another column I'm now getting this error:

 

image.png

 
 

Neither of these columns are referencing each other, but can be looking at some of the same tables/columns to derive their results. Any thoughts on this one?

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.