Forum Discussion
SQL logic in DAX
I have a SQL logic count ( distinct(PurchaseOrder) | |SubOrder. How to translate it in DAX,
I tried as CALCULATE( COUNT(SubOrder),DISCTINCTCOUNT(PurchaseOrder) But I dId not get the correct resutl
Thanks
Hi BishwaR ,
Just use Count() directly to create measure:
Count Suborders = COUNT('Table'[Suborder])Attached the sample file in the below, hopes it could help.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
6 Replies
- selimovd
Most Valuable Professional
Hey BishwaR ,
what exactly do you want to do?
In a measure you can only get one result, so either the count of SubOrder or the Distinctcount of PurchaseOrder.
Help me a little to understand better your problem, then I'm confident that we can find a solution.
If you need any help please let me know.If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍Best regardsDenisBlog: WhatTheFact.bi- BishwaR
Helper V
Each Purchase Order has sub orders.
If PO 12 has three Suborders
PO 22 has one Suborder
PO 33 has four suborder
then I am trying to show in the report
PO 12 has 3 suborders
PO 22 has 1 suborders
PO 33 has 4 suborder
TOTAL suborders 8
Thank you
- selimovd
Most Valuable Professional
How does that look in the data model? Do you have one table with the PO and one table with the Suborders and they are connected with a relationship?
Or do you have one table for the Suborders with a column for the PO?
The reason I'm asking is that different data models need different approaches. If you could show a picture of the data model and the tables that would help a lot. Then I can tell you the measure.
Best regards
Denis