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

In Stock by Date

Hi,

 

I am trying to calculate in stock rates as a measure and am having trouble writing the DAX.

 

I have item, store, date, inventory, and approved.

 

I would like to have a measure that has (# of stores with inventory/# of stores approved) by item and by day. Ideally we'd then be able to slice by higher item-category levels or by month to date etc.

 

 

Any help would be appreciated.

2 REPLIES 2
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

Add fields [item] and [date] (set its type to hierarchy and remove all levels expect for day) into visual. The measure could be similar to:

Measure =
CALCULATE (
    COUNT ( Table[stores] ),
    FILTER ( ALLSELECTED ( Table ), Table[inventory] <> BLANK () )
)
    / CALCULATE (
        COUNT ( Table[stores] ),
        FILTER ( ALLSELECTED ( Table ), Table[approved] = "yes" )
    )

For more advice, please provide sample data and desired result. How to Get Your Question Answered Quickly

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you @v-yulgu-msft for your help!

 

That's definitely progress!

 

I ended up doing the following, which gets my desired result, but I am unable to do visualization filtering based on items/hierarchy. In addition I have a store hierarchy that I would filter by (maps, etc.) The percent is static so just need a little bit more help!!

 

Measure = CALCULATE ( COUNT ( Table[Store] ), FILTER ( ALLSELECTED ( Table ), Table[Approved] = TRUE() ), FILTER ( ALLSELECTED ( Table ), Table[Inventory] > 0 ) ) / CALCULATE ( COUNT ( Table[Store] ), FILTER ( ALLSELECTED ( Table ), Table[Approved] = TRUE() ) )

 

 

I have dummy data I can attach as well. Here is a snapshot.

 

DateStoreItemInventoryApprovedItem Level 1Item Level 2Item Level 3Item Level 4
9/16/20185088brussels sprouts10II4I453I453VV
9/16/20182839cabbage140SS2S200S200BW
9/16/20183475celery80TT2T2X3T2X3YC
9/20/20184323eggplant1690SS4S400S400BA
9/20/20187188leeks120II9I933I933MI
9/20/20184516lettuce60II1I108I108F1
9/20/20182682mushrooms50II9I943I943MT
9/20/20184104radishes130SS2S219S219BN
9/20/20183454squash161SS6S601S601D2
9/20/20185600swiss chard50SS2S208S208C2
9/20/20183277turnips120II7I753I753LG
9/20/20183764zucchini60II9I933I933MI

 

 

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.