Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
I need to create a calculated column which will contain a rank value but this will be based on multiple columns: The sample data is as below : I need to create a Rank column and its shoulbe grouped by statment_id and ordered by Line_id.
Example: For statement_id = 400, line_id 321 should get Rank 1, line_id = 303 should get Rank 2 For statement_id = 100, line_id 222 should get Rank 1, line_id = 221 should get Rank 2
Sample Data:
| statement_id | line_id | value_date | Actv_Flag |
| 400 | 321 | 5/15/2019 | Y |
| 400 | 321 | 5/15/2019 | Y |
| 400 | 303 | 5/13/2019 | Y |
| 400 | 303 | 5/13/2019 | Y |
| 100 | 222 | 4/9/2019 | Y |
| 100 | 222 | 4/9/2019 | Y |
| 100 | 221 | 4/9/2019 | Y |
| 100 | 221 | 4/9/2019 | Y |
| 100 | 202 | 4/1/2019 | Y |
| 100 | 202 | 4/1/2019 | Y |
| 608 | 553 | 4/10/2018 | Y |
| 608 | 553 | 4/10/2018 | Y |
| 608 | 552 | 6/26/2019 | Y |
| 608 | 552 | 6/26/2019 | Y |
| 608 | 551 | 6/26/2019 | Y |
| 608 | 551 | 6/26/2019 | Y |
Expected Result:
| statement_id | line_id | value_date | Actv_Flag | Rank |
| 400 | 321 | 5/15/2019 | Y | 1 |
| 400 | 321 | 5/15/2019 | Y | 1 |
| 400 | 303 | 5/13/2019 | Y | 2 |
| 400 | 303 | 5/13/2019 | Y | 2 |
| 100 | 222 | 4/9/2019 | Y | 1 |
| 100 | 222 | 4/9/2019 | Y | 1 |
| 100 | 221 | 4/9/2019 | Y | 2 |
| 100 | 221 | 4/9/2019 | Y | 2 |
| 100 | 202 | 4/1/2019 | Y | 3 |
| 100 | 202 | 4/1/2019 | Y | 3 |
| 608 | 553 | 4/10/2018 | Y | 1 |
| 608 | 553 | 4/10/2018 | Y | 1 |
| 608 | 552 | 6/26/2019 | Y | 2 |
| 608 | 552 | 6/26/2019 | Y | 2 |
| 608 | 551 | 6/26/2019 | Y | 3 |
| 608 | 551 | 6/26/2019 | Y | 3 |
Thanks in advance 🙂
Solved! Go to Solution.
Hi @Anonymous ,
Create the following calculated column to your table:
Rankin =
RANKX (
FILTER ( 'Table'; 'Table'[statement_id] = EARLIER ( 'Table'[statement_id] ) );
'Table'[line_id];
;
DESC;
DENSE
)
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @Anonymous ,
incase you wan to create a Calculated COlumn
RANKing Group = RANKX(FILTER('Table','Table'[statement_id] = EARLIER('Table'[statement_id])),'Table'[line_id],,DESC,DENSE)
Incase you want to create a measure
RANKing OrderId = RANKX(FILTER(ALL('Table'[statement_id],'Table'[line_id]), 'Table'[statement_id] = MAX('Table'[statement_id])),CALCULATE(SUM('Table'[line_id])))
Regards,
Harsh Nathani
Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!
Hi @Anonymous ,
incase you wan to create a Calculated COlumn
RANKing Group = RANKX(FILTER('Table','Table'[statement_id] = EARLIER('Table'[statement_id])),'Table'[line_id],,DESC,DENSE)
Incase you want to create a measure
RANKing OrderId = RANKX(FILTER(ALL('Table'[statement_id],'Table'[line_id]), 'Table'[statement_id] = MAX('Table'[statement_id])),CALCULATE(SUM('Table'[line_id])))
Regards,
Harsh Nathani
Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!
Hello how about it, how could you apply the calculated column you showed, but for more than one parameter? That is, I apply a RANK but according to four other columns (for example in my case YEAR, QUARTER, AGGLOMERATE and INCOME, and not just a column like the detailed one.
I thank you in advance! I can't find this solution anywhere.
Hi @Anonymous ,
Create the following calculated column to your table:
Rankin =
RANKX (
FILTER ( 'Table'; 'Table'[statement_id] = EARLIER ( 'Table'[statement_id] ) );
'Table'[line_id];
;
DESC;
DENSE
)
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsIf you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 37 | |
| 35 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 74 | |
| 72 | |
| 39 | |
| 35 | |
| 23 |