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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
liberty20
Frequent Visitor

ABC classification for 'same stock volume' since last 6/3/1 months.

Hi,

I am trying to create a bucket where I need to classify Items in the groups of A/B/C on the basis of available stock quantity.

For Example :

If an Item no. 20048 is having same quantity since last 6 months then it should be label as 'A' ;

If having same quantity since last 3 months then 'B' ;

If having same quantity since last 1 month then 'C'

 

Thank you in advance!

8 REPLIES 8
v-yangliu-msft
Community Support
Community Support

Hi  @liberty20 ,

 

Are there other tables included in Visual, can you share your PBIX to delete sensitive data, we can help you better.

 

Best Regards,

Liu Yang

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

Hi @v-yangliu-msft ,

We are referring to single table only.

I am just trying to highlight the products which are having same quantity (i.e. not sold) since last 6 months or since 3 months or since 1 month.

v-yangliu-msft
Community Support
Community Support

Hi  @liberty20 ,

 

Here are the steps you can follow:

1. Create measure.

Measure =
var _date=MAXX(FILTER(ALL('Table'),'Table'[Item NO]=MAX('Table'[Item NO])),[Month-Year])
var _maxxdate=MONTH(MAXX(FILTER(ALL('Table'),'Table'[Item NO]=MAX('Table'[Item NO])),[Month-Year]))
var _1month=DATE(YEAR(_date),MONTH(_date)-1,1) //2022.7.1
var _3month=DATE(YEAR(_date),MONTH(_date)-2,1) //2022.6.1
var _6month=DATE(YEAR(_date),MONTH(_date)-5,1) //2022.3.1
var _sum1=SUMX(FILTER(ALL('Table'),'Table'[Item NO]=MAX('Table'[Item NO])&& 'Table'[Month-Year]>=_1month &&'Table'[Month-Year]<=EOMONTH(_date,0)),[Qty])
var _sum3=SUMX(FILTER(ALL('Table'),'Table'[Item NO]=MAX('Table'[Item NO])&& 'Table'[Month-Year]>=_3month&&'Table'[Month-Year]<=EOMONTH(_date,0)),[Qty])
var _sum6=SUMX(FILTER(ALL('Table'),'Table'[Item NO]=MAX('Table'[Item NO])&& 'Table'[Month-Year]>=_6month&&'Table'[Month-Year]<=EOMONTH(_date,0)),[Qty])
var _summax=SUMX(FILTER(ALL('Table'),'Table'[Item NO]=MAX('Table'[Item NO])&&'Table'[Month-Year]>=DATE(YEAR(_date),MONTH(_date),1)&&'Table'[Month-Year]<=EOMONTH(_date,0)),[Qty])
return
IF(
MOD(_sum6,_summax)=0,"A",
IF(
MOD(_sum3,_summax)=0,"B",
IF(
MOD(_sum1,_summax)=0,"C")
))

2. Result:

vyangliumsft_0-1666862994978.png

 

Best Regards,

Liu Yang

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

Hi @v-yangliu-msft,

Many thanks for your quick responses!!

Followed the same steps and created measure successfully without any error, but in terms of ABC classification few results are not properly getting categorized.

Example:

liberty20_0-1666865866989.png

 

v-yangliu-msft
Community Support
Community Support

Hi  @liberty20 ,

I created some data:

vyangliumsft_0-1666770058078.png

Here are the steps you can follow:

1. Create Measure.

Measure =
var _today=TODAY()
var _last1month=DATE(YEAR(_today),MONTH(_today)-1,DAY(_today))
var _last2month=DATE(YEAR(_today),MONTH(_today)-2,DAY(_today))
var _last3month=DATE(YEAR(_today),MONTH(_today)-4,DAY(_today))
var _last6month=DATE(YEAR(_today),MONTH(_today)-7,DAY(_today))
var _label1=SUMX(FILTER(ALL('Table'),'Table'[Item no]=MAX('Table'[Item no])&&'Table'[Date]>_last2month&&'Table'[Date]<=_last1month),[Amount])
var _label2=SUMX(FILTER(ALL('Table'),'Table'[Item no]=MAX('Table'[Item no])&&'Table'[Date]>_last3month&&'Table'[Date]<=_last1month),[Amount])
var _label3=SUMX(FILTER(ALL('Table'),'Table'[Item no]=MAX('Table'[Item no])&&'Table'[Date]>_last6month&&'Table'[Date]<=_last1month),[Amount])
var _group=SUMX(FILTER(ALL('Table'),'Table'[Item no]=MAX('Table'[Item no])&&'Table'[Date]>_last1month&&'Table'[Date]<=_today),[Amount])
return
IF(
_group=_label1,"A",
IF(
_group=_label2,"B",
IF(
_group=_label3,"C",1)))

2. Result:

vyangliumsft_1-1666770058079.png

Best Regards,

Liu Yang

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

Thank you @v-yangliu-msft , but this solution is not working in my case.

Sample data:

liberty20_0-1666857891466.png

Expected Result:

liberty20_1-1666857978113.png

amitchandak
Super User
Super User

@liberty20 , Try a measure like 

ABC =
var _6 = CALCULATE(sumx(Values('Date'[Month]), calculate(if([MTD Sales] = [Last Mtd Sales],0,1)),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-6,MONTH))
var _3 = CALCULATE(sumx(Values('Date'[Month]), calculate(if([MTD Sales] = [Last Mtd Sales],0,1)),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-3,MONTH))
var _1 = if([MTD Sales] = [Last Mtd Sales],0,1)
return
Switch( True() ,
not(isblank(_6)) && _6 =0 , "A",
not(isblank(_3)) && _6 =0 , "B",
"C"
)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thank you @amitchandak, but this solution is not working in my case.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.