The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
In my order lines table, I want a calculated column that shows the number of order lines of that order. So for each order line, I want to know how many order lines there are with a similar OrderID. One other filter that needs to be applied is that the LineNumber cannot be 0. Line number zero's need to be excluded, because those are order headers in my data.
Solved! Go to Solution.
It will be better you paste a sample of data (remove the key identifiers and a sample is good)
Let us say, assuming you have a table called TableOrder. order_id column is unique for each order and line_number is within each order and you can start with like below ...
[Items per Order] =
var _currOrderID = TableOrder[order_id]
return
COUNTX(
filter(
TableOrder,
TableOrder[order_id] = _currOrderID && TableOrder[line_number] > 0
),
TableOrder[line_number] -- you can use any primary key column of the TableOrder
)
Hi @BBConsultancy ,
I made simple samples and you can check the results below:
Measure = CALCULATE(COUNT('Table'[ID]),ALLEXCEPT('Table','Table'[Category]))
An attachment for your reference. Hope it helps!
Best regards,
Community Support Team_ Scott Chang
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
It will be better you paste a sample of data (remove the key identifiers and a sample is good)
Let us say, assuming you have a table called TableOrder. order_id column is unique for each order and line_number is within each order and you can start with like below ...
[Items per Order] =
var _currOrderID = TableOrder[order_id]
return
COUNTX(
filter(
TableOrder,
TableOrder[order_id] = _currOrderID && TableOrder[line_number] > 0
),
TableOrder[line_number] -- you can use any primary key column of the TableOrder
)
Thank you, this works perfectly!
User | Count |
---|---|
25 | |
12 | |
8 | |
8 | |
5 |
User | Count |
---|---|
28 | |
13 | |
12 | |
12 | |
6 |