Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Categorize Values by Timeframe

Hi, community,

 

I have a matrix that looks like this:

 

ITEM STOCK 
Week Number / Week Start1234567
Item1/01/20217/01/202114/01/202121/01/202128/01/20215/02/202112/02/2021
a -2    -11
b3-4  5  
c6 5   -10
d7 5  7-7

 

I want to create a table/matrix that has an indicator for negative stocks over the next 6 weeks. Based on the table above, it should look like this.

 

Negative Stocks
ItemNegative in 6 weeks
aY
bY
dN

 

Thanks

Evan

6 REPLIES 6
Anonymous
Not applicable

Hi @Anonymous 

As you said , negative is < 0 . Do you mean that the value of the seventh week is less than 0 ?If yes , then the result returned by d should also be Y. But the result you provided is N.

Ailsamsft_0-1625540779939.pngAilsamsft_1-1625540779943.png

So your definition of negative is still not very clear , If possible, please give a detailed description of negative .

 

Best Regards

Community Support Team _ Ailsa Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

@Anonymous ,

Y is only for negative in 6 weeks. Week 7 should not be included in this.

Anonymous
Not applicable

Hi @Anonymous 

What is the rule for you to judge negative? At present, from the data you provided, I have no way to judge under what circumstances it is negative and under what circumstances it is not? It would be great if you can provide specific judgment rules .

 

Best Regards

Community Support Team _ Ailsa Tao

Anonymous
Not applicable

Hi, @Anonymous ,

 

Negative is < 0.

 

Thanks

amitchandak
Super User
Super User

@Anonymous , Assume you have data in unpivoted format or you can unpivot it in power query having dates on row, and then can create a date table and a week rank on that

 

Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

 

Stock = if(sum(Table[Qty])<0,1,0) 

 


negative ove last 6 week = if( countx(values(Table[Weel]), calculate([Stock ],FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-6 && 'Date'[Week Rank]<=max('Date'[Week Rank])))) >0, "Yes", "No")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak,

Thanks for the reply.

 

What does Table[Weel]) refer to?

 

Thanks

Evan

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors