Forum Discussion
Showing zero on a line graph using DimDate
- 4 years ago
Thank you for this! I had seen a similar solution posted elsewhere, but I had some confusion with which measure I was adding zero to since I don't have any measures already applied to this particular graph.
The solution that ended up working for me was to create a DimDate table and follow the steps and add the code from this site. One change I had to make was to use Date.EndofMonth instead of Date.EndofYear, because I only wanted it to count this year's data up to this month since the remaining months in this year haven't happened yet.
Then I had to create a relationship between the date column in my original table and the date column in the DimDate table. Then I added the following DAX expression to my new table:
COUNT OF INCIDENTS =
VAR _INCIDENTS = COUNT ('Table name'[Column name])
RETURN
IF (ISBLANK(_INCIDENTS),0,_INCIDENTS)
Thank you for this! I had seen a similar solution posted elsewhere, but I had some confusion with which measure I was adding zero to since I don't have any measures already applied to this particular graph.
The solution that ended up working for me was to create a DimDate table and follow the steps and add the code from this site. One change I had to make was to use Date.EndofMonth instead of Date.EndofYear, because I only wanted it to count this year's data up to this month since the remaining months in this year haven't happened yet.
Then I had to create a relationship between the date column in my original table and the date column in the DimDate table. Then I added the following DAX expression to my new table:
COUNT OF INCIDENTS =
VAR _INCIDENTS = COUNT ('Table name'[Column name])
RETURN
IF (ISBLANK(_INCIDENTS),0,_INCIDENTS)
Hi ld17 ,
Since you didn't have a measure, are you putting a column or a calculated column?
Then you can create a measure, use the SUM function to get the sum of the fields you want, and then add 0.
For example,
Measure = SUM('Table'[ColumnNmae]) + 0
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.