Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi everybody
I have a dataset such as the following:
Customer ID. TransactionDate(UK format)
CUST001. 12/2/24
CUST001. 13/2/24
CUST001. 14/2/24
CUST002. 12/2/24
CUST002. 13/2/24
CUST002. 14/2/24
I'm trying to write DAX or write some M Code to Rank each of the transactions per customer in date order.
The solution I am looking for would be a column which reads
1
2
3
1
2
3
(this is based on my example above)
Many thanks
Solved! Go to Solution.
Using DAX :
TransactionRank =
RANKX(
FILTER(
'YourTableName',
'YourTableName'[Customer ID] = EARLIER('YourTableName'[Customer ID])
),
'YourTableName'[TransactionDate],
,
ASC,
Dense
)
Using M :
= Table.Group(
YourTableName,
["Customer ID"],
{
"Data",
each Table.AddIndexColumn(
Table.Sort(_, {"TransactionDate", Ascending}),
"TransactionRank",
1,
1,
Int64.Type
),
type table
}
)
Using DAX :
TransactionRank =
RANKX(
FILTER(
'YourTableName',
'YourTableName'[Customer ID] = EARLIER('YourTableName'[Customer ID])
),
'YourTableName'[TransactionDate],
,
ASC,
Dense
)
Using M :
= Table.Group(
YourTableName,
["Customer ID"],
{
"Data",
each Table.AddIndexColumn(
Table.Sort(_, {"TransactionDate", Ascending}),
"TransactionRank",
1,
1,
Int64.Type
),
type table
}
)
Thank you so much
Welcome ! Good luck with M it is a little bit tricky sometime 😄
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
84 | |
76 | |
73 | |
42 | |
36 |
User | Count |
---|---|
109 | |
56 | |
52 | |
48 | |
43 |