Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Dear,
We have a particular business case where we have multiple documents and multiple status per document.
We would like to count the distinct number of documents per status but avoiding double counting (e.g. when a document having multiple status rows). There is no field like last creation date or last status, we can only detect the correct count based on the dimension where we have an order of priority. See example below, I have added the dimension details...
E.g. DocumentId 1 has both a StatusID 1 and 2 , but based on the dimension table, we know that StatusID 2 has the highest priority (=the lower the number the higher the priority - but not so important) . Therefore when we count by status, the DocumentId should be counted with StatusID 2 only and not for StatusID 1.
Unfortunately, I'm quite new in Power BI and DAX and I could not find a function to derive this.
Anyone a suggestion ?
@Anonymous
Because the filter expression is max([status id], if you want filter based on the priority. Try change the underlined part to min([Priority]), keeps others the same.
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
Hi,
That's not fully correct.What I need is to get the minimum priority per documentId and as such I know the corresponding Status(Id).
I tried to implement it :
But the result is not correct:
I become StatusID 3 = count of 4 (all documents)
While the count result should be :
StatusID 1 = 1 (DocumentId 2)
StatusID 2 = 1 (DocumentId 1)
StatusID 3 = 3 (DocumentId 3, 4,5)
StatusId 4 = 0
What is wrong with my measure ?
@tvw83 , Few ways. Create a rank column and filter on 1.
rank column = rankx(filter(Table, [document_id] = earlier([document_id])), [Status_id],,desc,dense)
or try a measure like this.
measure = calculate(count(Table[document_id]), filter(Table , Table[status]= calculate(max([Status_id]),allexcept(Table,table[document_id]))))
Hi amitchandak,
Unfortunately that is not completely what I'm looking for. I would like to sort/rank based on a field in the dimension table (dimPriority) that is not in the fact table. In my sample, I have put them in one table, but only StatusId is the key between both fact table and dimension.
By coincidence, the result is the same if you sort on StatusID but that is not what I need.
Question is thus, how do I sort/rank in the Fact Table (DocumentId, Date, StatusID) based on a field in the Dimension Table (dimPriority) ?
Thank you in advance
To help suggest a specific expression, please provide an example of a visual (e.g., table or matrix) you would make that shows the correct result in context.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Hi, I slightly changed the data to show a real case.
Below printscreen of the relationship. I would like to count based on the field Priority in the dimension table.
And hereafter a printscreen of the Fact, Dimension tables as matrix.
Please look at DocumentId 5, it should be counted once for StatusID=3 and not StatusID 4. Why ? Based on the priority (the lower the more important), StatusID 3 is prior. So I would like to count it for that status.
But for this, I need to be able to sort based on the Priority column.
Any suggestion ?
Kr
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
90 | |
87 | |
84 | |
66 | |
49 |
User | Count |
---|---|
131 | |
110 | |
96 | |
70 | |
67 |