Forum Discussion
Bar chart: Avoiding bars without value with an condition!
- 2 years ago
Now I understand that you want to show blanks for weeks before the FirstVisitDate. If your current formula is still showing 0 for those weeks, you should make sure to adjust the formula accordingly. It seems like there might be an issue with the logic. You can update your DAX formula to achieve the desired result:
Visitors =
VAR FirstVisitDate = CALCULATE(MIN('Usage_log'[Date]), ALL('Usage_log'))
VAR WeekDate = SELECTEDVALUE(DateTable[StartDate])
VAR VisitorCount =
CALCULATE(
DISTINCTCOUNT(Usage_log[user_Id]),
ALL(Usage_log),
KEEPFILTERS(ALL('User_Categorization_Revised'[User_Type]))
)
RETURN
IF (
WeekDate < FirstVisitDate,
BLANK(),
IF(VisitorCount > 0, VisitorCount, BLANK())
)In this modified formula, it explicitly returns BLANK() when WeekDate < FirstVisitDate, ensuring that weeks before the first visit date are left blank. Additionally, it checks for VisitorCount > 0 to decide whether to show the actual visitor count or a blank.
Please make sure that your DateTable and 'Usage_log' table have the appropriate relationships and that the data types of 'Date' and 'StartDate' columns match for the comparison to work correctly.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.