cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
alisaleh
Helper I
Helper I

replacing blank with 0 cause the filter not to work correctly

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.

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

@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 ) )

View solution in original post

2 REPLIES 2
alisaleh
Helper I
Helper I

Thanks. it put me on the right path.

tamerj1
Super User
Super User

@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 ) )

Helpful resources

Announcements
collabdays lisbon

CollabDays Lisbon - 26 November 2022

Sessions include practical, hands-on experience that will help you take the next step in your career and know-how.

Difinity Conference

Difinity Conference 2022

Difinity is the largest Microsoft Data, AI, Power BI, Power Platform and Business Applications Conference in New Zealand.

European Share Point Conference

European Share Point Conference

This conference returns live and in-person in Copenhagen this 28 November-01 December with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Microsoft 365 Conference â__ December 6-8, 2022

Microsoft 365 Conference - 06-08 December

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.