Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hi,
I have scenario where I have 1:* active relationship from project table to JobCard table. I have created a measure to count the number of Job Card based on selected Project where I have project slicer. The DAX for the measure is as follows:
Total Project Job Card =
var temp= CALCULATE(COUNT('jobCard'[id]),'jobCard'[project] == SELECTEDVALUE('Project'[name]))
return If(ISBLANK(temp),0,temp)
The problem Im having is when I change the project in the slicer its always showing job cards from anohter
project with 0 values for total. If I remove the condition to replace blank with 0 then it filters correctly
and when I select project with no job cards nothing shows!! why this is happening desipite the measure is filter
by selected project? How do I fix it so it shows 0 for blanks when there is job card associated with the project and show nothing when there is no association.
Solved! Go to Solution.
Please try
Total Project Job Card =
VAR temp =
CALCULATE (
COUNT ( 'jobCard'[id] ),
'jobCard'[project] == SELECTEDVALUE ( 'Project'[name] )
)
RETURN
IF ( NOT ISEMPTY ( 'jobCard' ), COALESCE ( temp, 0 ) )
Thanks. it put me on the right path.
@alisaleh Do you recall how you got the formula to work? I was running into the issue where the is not empty excludes my blanks, so the coalesce never gets the chance to return the 0.
@tamerj1 I found the issue. Ill use the same names as the OP. I adjusted your formula to put the Project table into the Not ISempty function rather than the jobcard table.
My issue with the formula was we want to replace the blanks when that jobcard table is blank, so the function you had skips the coalesce in this case; but works well when putting the project table there. I think this was the same issue @alisaleh
Please try
Total Project Job Card =
VAR temp =
CALCULATE (
COUNT ( 'jobCard'[id] ),
'jobCard'[project] == SELECTEDVALUE ( 'Project'[name] )
)
RETURN
IF ( NOT ISEMPTY ( 'jobCard' ), COALESCE ( temp, 0 ) )
What an odd workaround but this answer is exactly what I needed today for this very issue. I would have never figured this out. Thanks.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 51 | |
| 37 | |
| 35 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 70 | |
| 64 | |
| 39 | |
| 33 | |
| 23 |