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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
tonny_bwg
Helper I
Helper I

rank with inventory value of previous month

Dear Guru:

I want to write measure to rank material with the inventory value of previous month.  I've created a measure to rank the material with current inventory value(selected period). I want to show the rank change between selected period and (selected period -1). below is the measure I create:

Rank_test =
  VAR items = ALLSELECTED(fct_Inventory)
  VAR _curvalue = [Sum of Value]
  VAR _VRank = COUNTROWS( FILTER( items, fct_Inventory[TOTAL_VALUE] >=_curvalue))
  Return
   if(_VRank=0,1,_VRank)
How to modify it. BTW,  I've applied these slicers on the page to select plant, material type, period.
tonny_bwg_0-1689930675186.png

thanks for the help.

 

--Tonny

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @tonny_bwg ,

You can try using the following dax:

Measure =
var _selectYearMonth=SELECTEDVALUE('Table'[YearMonth])
var _date=
MINX(
    FILTER(ALL('Table'),
    'Table'[YearMonth]=_selectYearMonth),[Date])
var _maxdate=
EOMONTH(_date,-1)
var _mindate=
EOMONTH(_date,-2)
return
RANKX(
    FILTER(ALLSELECTED('Table'),
    'Table'[Date]>_mindate&&'Table'[Date]<=_maxdate),CALCULATE(SUM([Value])),,ASC)

Can you share sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you

 

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

could you please help to solve this issue? 

Hi,Mr. LiuYang

appreciated your help. please use this sample file to create previous month's rank. thanks 

tonny_bwg
Helper I
Helper I


the fact table is as below, and a Dim_date table, a dim_Area tbl, Dim_material table link to fact table.  
my question is how to calcualte previous month rank based on current filter context.

thanks for your help.
--Tonny

tonny_bwg_1-1689946506547.png

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.