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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Sandeep13
Helper III
Helper III

Rank function Based on ReportedDate like YYYYMM

Hi All,

 

I have 2 columns reporting_mth and Amount, I want to create rank based on reporting_mth and sort data based on amount.

 

Now If you see i have 202203 and 202212 in my data. I am expecting ouput like  

Sandeep13_0-1686917421672.png

I am expecting output like below .if we have 2 same reportingmonth with different monthnumber  than always give  max Outstanding Amount as rank 1.

 

reporting_mthOutstanding AmountRank
20180329963009505801
20190334310785593351
20200338651453062211
20210340570195156711
20220344067092767762
20221249921657579651

 

@ranku @PoiwerBInovice @po @PowerZ @PBCommunity 

 

10 REPLIES 10
Anonymous
Not applicable

Hi @Sandeep13 

You can create a measure

Measure = var a=LEFT(SELECTEDVALUE('Table'[reporting_mth]),4)
return RANKX(FILTER(ALLSELECTED('Table'),LEFT([reporting_mth],4)=a),CALCULATE(SUM('Table'[Outstanding Amount])),,DESC,Dense)

vxinruzhumsft_0-1687228800347.png

 

Best Regards!

Yolo Zhu

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

Ahmedx
Super User
Super User

Hey While using your code i am getting error massage.

the query referenced calculated column which does not hold any data there is an error in its expression.

 

 

 

 

Share sample pbix file to help you.

Hi Thanks for your reply.

 

For me I dont see attached option here becuase I am not a super user.

 

I have uploaded file in powerbi services. below is link for your refernce,.

Let me know if you are not able to open the link.
If possible share me your email id so i can give you persmission dirclty 

Power BI

Ahmedx
Super User
Super User

Order = 
VAR _t = LEFT( MAX( [reporting_mth],4))
RETURN 
    RANKX(
         FILTER(ALL('Table'), 
          LEFT('Table'[reporting_mth],4)=_t),
            [reporting_mth],,DESC)

Still some issue.
I am Passing dax in measure.

Sandeep13_0-1686930689651.png

Getting below errro msg.

A single value for column 'reporting_mth' in table 'Port_Append' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

Ahmedx
Super User
Super User

pls try this

Screen Capture #1261.png

you create a column, you don't need to create a measure

Hi thank you for your response but its give me error.

 

reporting_mth is a column in my data.

 

Sandeep13_0-1686929789048.png

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.