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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
gthistlethwaite
Frequent Visitor

ISBLANK in If to show a zero

I have a DAX Function whereby I display a number based from Today's date minus the last incident date. I have to add the "+0", as I display this result in a Card, and when has never been a zero, and the Card will not display "(Blank)". _DaysSinceLastIncident = IF( ISBLANK([_DateOfLastIncident]), BLANK(), VALUE(TODAY() - [_DateOfLastIncident])) + 0 The issue comes when we choose a location which has never reported an incident, and so we would like to display today's date, minus the date we started to capture (01/01/2017). Currently, they return a "0", which causes confusion as that would mean they have had an incident Today. Many thanks, Gary
1 ACCEPTED SOLUTION
Seward12533
Solution Sage
Solution Sage

I woudl recommend something like the following

 

DateStartedCapture=DATE(2017,1,1)

DaysSinceLastIncident = 
  VAR DeltaDateRAW = TODAY()-[DateOfLastIncident] RETURN
  IF(DELTA=TODAY(),TODAY()-[DateStartedCapture],DELTA)

 

Tipe, you don't need specify the ISBLANK() or return a BLANK() these are implied by DAX

 

IF([DateOfLastIncident],[result]) will do the trick.  just putting a measure in the logical test of an IF is like saying IF "it has a value" then (i.e. NOT(ISBLANK()) and you don't need to specify an ELSE in DAX it will return null (i.e. BLANK()) as the else by default. 

 

Rather than use +0 to force a zero result here is how I like to handle it. 

 

MEASURE = VAR Result = CALCULATE(...) RETURN

IF([RESULT],[RESULT],0)

 

View solution in original post

1 REPLY 1
Seward12533
Solution Sage
Solution Sage

I woudl recommend something like the following

 

DateStartedCapture=DATE(2017,1,1)

DaysSinceLastIncident = 
  VAR DeltaDateRAW = TODAY()-[DateOfLastIncident] RETURN
  IF(DELTA=TODAY(),TODAY()-[DateStartedCapture],DELTA)

 

Tipe, you don't need specify the ISBLANK() or return a BLANK() these are implied by DAX

 

IF([DateOfLastIncident],[result]) will do the trick.  just putting a measure in the logical test of an IF is like saying IF "it has a value" then (i.e. NOT(ISBLANK()) and you don't need to specify an ELSE in DAX it will return null (i.e. BLANK()) as the else by default. 

 

Rather than use +0 to force a zero result here is how I like to handle it. 

 

MEASURE = VAR Result = CALCULATE(...) RETURN

IF([RESULT],[RESULT],0)

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.