Forum Discussion
Dynamic date axis on chart showing dates with no data
- 4 years ago
Hi huguestremblay ,
I do not see the bar chart as your screenshot in your pbix file, please check it.
I have a method you can try.
1 Create a date table for the slicer.Date for slicer = VALUES('Table'[Date])
2 Create a measure as follows:Measure = VAR _count = IF( ISBLANK( SUM( 'Table'[Values] ) ), 0, SUM( 'Table'[Values] ) ) VAR _mindate = MIN( 'Date for slicer'[Date] ) VAR _maxdate = MAX( 'Date for slicer'[Date] ) RETURN IF( AND( DATE( SELECTEDVALUE( 'Table'[Date].[Year] ), SELECTEDVALUE( 'Table'[Date].[MonthNo] ), 1 ) >= _mindate, DATE( SELECTEDVALUE( 'Table'[Date].[Year] ), SELECTEDVALUE( 'Table'[Date].[MonthNo] ) + 1, 1 ) - 1 <= _maxdate ), _count, BLANK() )3 Uncheck "show items with no data"
Result:
Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi huguestremblay ,
I do not see the bar chart as your screenshot in your pbix file, please check it.
I have a method you can try.
1 Create a date table for the slicer.
Date for slicer = VALUES('Table'[Date])
2 Create a measure as follows:
Measure =
VAR _count =
IF( ISBLANK( SUM( 'Table'[Values] ) ), 0, SUM( 'Table'[Values] ) )
VAR _mindate =
MIN( 'Date for slicer'[Date] )
VAR _maxdate =
MAX( 'Date for slicer'[Date] )
RETURN
IF(
AND(
DATE( SELECTEDVALUE( 'Table'[Date].[Year] ), SELECTEDVALUE( 'Table'[Date].[MonthNo] ), 1 ) >= _mindate,
DATE( SELECTEDVALUE( 'Table'[Date].[Year] ), SELECTEDVALUE( 'Table'[Date].[MonthNo] ) + 1, 1 ) - 1 <= _maxdate
),
_count,
BLANK()
)
3 Uncheck "show items with no data"
Result:
Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello,
What I need is a DISTINCTCOUNT (not a SUM) so I have udpated your measure accordingly and it appears to work in my test report. I will transfer to my full report now.
Thank you!