Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Create a DAX measure/ column to count rows in a table that has Self join condition

Hi folks,

I want to achieve the following SQL in Power BI DAX :

 

select count(Parent.RegNum)
from WorkItem Parent
inner join WorkItem Child on (Parent.SourceRegNum = Child.RegNum)
where Child.ItemCode='Template'
and Parent.IsDeleted='False'

 

My objective is to display count(parent.RegNum) against each child.RegNum in a chart. I know this is achievable if I had two different tables, one for Parent and one for Child using the DAX below :

countRows = VAR template = CALCULATE(COUNTROWS(Parent), FILTER(Parent, 'Parent'[SourceRegNum] = 'Child'[RegNum])) VAR template_final = IF(template > 0, template , 0) RETURN template _final

& using Child.ItemCode='Template' and Parent.IsDeleted='False' as Page level filter.

 

But unfortunately this doesn't work since I am having one one table(Parent).

Any suggestions would be greatly appreciated.

@dax , @Anonymous 

0 REPLIES 0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors