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
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
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.