Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I want to rank within the InvoiceNumber group by CreatedDate, the latest date should be rank 1. There are two InvoiceNumber in the below data 408 and 449.
I have created a measure to do the ranking:
InvoiceRankInTimePeriod =
VAR CreatedDate = [CreatedDateMin]
VAR Invoices =
CALCULATETABLE ( 'Data InvoiceFact', ALLSELECTED ( 'Data InvoiceFact' ), Values('Data InvoiceFact'[InvoiceNumber]) )
VAR InvoiceRank =
RANKX ( Invoices, VALUE(FORMAT([CreatedDateMin], "YYYYMMDDHHmmss") + [InvoiceKeyMin]))
VAR Result =
IF ( NOT ISBLANK ( CreatedDate ), InvoiceRank )
RETURN
Result
The ranking works:
I am wondering why it works, in particular what is VALUES doing within the CALUCLATETABLE function.
Hi,
The VALUES function creates a virtual table with all unique values of Invoice Number.
It's very close to DISTINCT function, even though soem diffrences might appear in some calculations.
To have more details on both functions, please refer to :
and
Hope it makes more sense for you
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 |
---|---|
14 | |
10 | |
10 | |
10 | |
9 |
User | Count |
---|---|
20 | |
13 | |
12 | |
11 | |
8 |