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
FrustratedUser3
Frequent Visitor

Replacing blank values with zero is messing up my Date slicer

My main table has TimeEntry records with the fields: DateRecorded (date), TimeRecorded (decimal) and Person (string).

I am trying to display a matrix with time entered for all persons between calendar dates, but also to display zero instead of blank/no value if the person has not added any record for a particular day. But when I add zeroes instead of blanks my existing date slicer filter will no longer work for date hierarchy.  Here are the steps I have done:

 

1. Create a calendar table using the MIN/MAX "DateRecorded" from my main table. I also added a relationship between my Calendar Table and main table by dragging the "Date" field to "DateRecorded" field.

 

 

Calendar Table = CALENDAR(MIN(TimeEntryTable[DateRecorded]),MAX(TimeEntryTable[DateRecorded]))

 

 

2. Add a Matrix to display information from my main table. Added the "PersonName" field to be Row,
"Date" from my calendar table to be Column, and "TimeRecorded" to be the Value. It is working fine to display
the person's recorded time shown here:

FrustratedUser3_0-1675036221279.png

But then I realized what if person has not entered any time on a particular day, but I want to display ZERO value instead of not having anything show up at all, so that I can see all days that persons have entered ZERO for blanks. I changed my "TimeRecorded" field to replace blanks with zeros using this measure:

 

 

FormatTimeEntered = IF(CALCULATE(SUM(TimeEntryTable[TimeRecorded]) = BLANK()), 0, CALCULATE(SUM(TimeEntryTable[TimeRecorded])))

 

 

And now my Matrix is displaying all of the dates, including where the person has not entered time with zeros. But this causes my existing Date Slicer to be broken. It only works with the default slicer, but if I try changing to Date Hierarchy and Year (e.g. I want to be able to select all time including zero values recorded for all Person in 2021) my matrix dates are not filtered properly and all dates for all years are showing.

How can I fix this? Thanks for any suggestions.

1 REPLY 1
amitchandak
Super User
Super User

@FrustratedUser3 , Try something like

 

0 between range
Measure = var _1= SUM(Opportunity[Opportunity count]) +0
var _min = minx(ALLSELECTED('Calendar'), 'Calendar'[Date])
var _max = maxx(ALLSELECTED('Calendar'), 'Calendar'[Date])
return
CALCULATE(if(max('Calendar'[Date]) <_min || max('Calendar'[Date]) >_max , BLANK(), _1))

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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