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
Hamdan1234
Helper III
Helper III

Count of months for available inventory based on material type

Hello,

I have below table and I want to count the number of month for which inventory was available. If inventory was available for 4 months it should show 4 if it is more than 12 months it should not show 12 just keep the limit to for each material inventory to 12 months. I have 4 columns Material, material inventory in hand, material inventory in transit and date. I made the measure to sum up the In hand and transit inventory. Now I want to calculate count of months for total inventory for each material. If the month count would be 3 if inventory was for 3 months september ,october and november. Similarly if the count of month has gone above 12 still it should show 12 count maximum as month should not go above 12. Help would be highly appreciated.

MaterialStock In handStock in transitTotal StockDate
A108441112530-Sep-20
B                 17093262.6760430-Sep-20
C                 9917997.5895630-Sep-20
A                 21884301.5916931-Oct-20
B                 68955743.8755431-Oct-20
C108522110731-Oct-20
A                   7167137.596730-Nov-20
B                   5166116.9519430-Nov-20
     
1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Hamdan1234 ;

You could create a measure as follows:

Count = 
var _count=CALCULATE(DISTINCTCOUNT('Table'[Date].[Month]),FILTER(ALL('Table'),'Table'[Material]=MAX('Table'[Material])&&[Total Stock]>0))
Return
IF(_count<=12,_count,12)

The final output is shown below:

vyalanwumsft_0-1635834002296.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yalanwu-msft
Community Support
Community Support

Hi, @Hamdan1234 ;

You could create a measure as follows:

Count = 
var _count=CALCULATE(DISTINCTCOUNT('Table'[Date].[Month]),FILTER(ALL('Table'),'Table'[Material]=MAX('Table'[Material])&&[Total Stock]>0))
Return
IF(_count<=12,_count,12)

The final output is shown below:

vyalanwumsft_0-1635834002296.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

rodrigosan
Resolver III
Resolver III

But for this forecast, is it not necessary to know the consumption of each item?

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.