<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Bar chart: Avoiding bars without value with an condition! in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Bar-chart-Avoiding-bars-without-value-with-an-condition/m-p/3498657#M134078</link>
    <description>&lt;P&gt;Hello kind people,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am creating a bar chart which represents the number of visitors per week. I want to keep those bars with 0 visitor in the chart, but only in those weeks after the original week when they have visited! Please see the graph below what I mean:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried with following DAX dreaming to fix the issue, but not working. Power BI had error message that&lt;FONT color="#FF0000"&gt; "&lt;SPAN&gt;the search text provided to function "find" could not be found in the given text" &lt;FONT color="#000000"&gt;even though I didn't even use Find function :O!&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Visitors = 
VAR FirstVisitDate = CALCULATE ( MIN ( 'Usage_log'[timestamp].[Date] ),  'Usage_log' )
VAR WeekDate = SELECTEDVALUE( DateTable[StartDate] )
VAR visitor =  CALCULATE (
    DISTINCTCOUNT(Usage_log[user_Id]),
    ALL(Usage_log),
    KEEPFILTERS(ALL('User_Categorization_Revised'[User_Type]))
)
RETURN
IF ( 
     WeekDate &amp;lt; FirstVisitDate,
     BLANK(),
     IF(ISBLANK(visitor) || visitor = 0, 0, visitor)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot in advance if you could help &lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 26 Oct 2023 10:47:47 GMT</pubDate>
    <dc:creator>Yiyi_1989</dc:creator>
    <dc:date>2023-10-26T10:47:47Z</dc:date>
    <item>
      <title>Bar chart: Avoiding bars without value with an condition!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Bar-chart-Avoiding-bars-without-value-with-an-condition/m-p/3498657#M134078</link>
      <description>&lt;P&gt;Hello kind people,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am creating a bar chart which represents the number of visitors per week. I want to keep those bars with 0 visitor in the chart, but only in those weeks after the original week when they have visited! Please see the graph below what I mean:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried with following DAX dreaming to fix the issue, but not working. Power BI had error message that&lt;FONT color="#FF0000"&gt; "&lt;SPAN&gt;the search text provided to function "find" could not be found in the given text" &lt;FONT color="#000000"&gt;even though I didn't even use Find function :O!&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Visitors = 
VAR FirstVisitDate = CALCULATE ( MIN ( 'Usage_log'[timestamp].[Date] ),  'Usage_log' )
VAR WeekDate = SELECTEDVALUE( DateTable[StartDate] )
VAR visitor =  CALCULATE (
    DISTINCTCOUNT(Usage_log[user_Id]),
    ALL(Usage_log),
    KEEPFILTERS(ALL('User_Categorization_Revised'[User_Type]))
)
RETURN
IF ( 
     WeekDate &amp;lt; FirstVisitDate,
     BLANK(),
     IF(ISBLANK(visitor) || visitor = 0, 0, visitor)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot in advance if you could help &lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 10:47:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Bar-chart-Avoiding-bars-without-value-with-an-condition/m-p/3498657#M134078</guid>
      <dc:creator>Yiyi_1989</dc:creator>
      <dc:date>2023-10-26T10:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: Bar chart: Avoiding bars without value with an condition!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Bar-chart-Avoiding-bars-without-value-with-an-condition/m-p/3498696#M134086</link>
      <description>&lt;P&gt;you want to create a bar chart in Power BI that shows the number of visitors per week, but you want to exclude weeks with 0 visitors unless those weeks come after the first week with visitors. Your DAX expression seems to be on the right track, but there are some issues in your code that need to be addressed.&lt;/P&gt;&lt;P&gt;Here's a revised version of your DAX formula:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Visitors =&lt;BR /&gt;VAR FirstVisitDate = CALCULATE(MIN('Usage_log'[timestamp].[Date]), ALL('Usage_log'))&lt;BR /&gt;VAR WeekDate = SELECTEDVALUE(DateTable[StartDate])&lt;BR /&gt;VAR VisitorCount =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;DISTINCTCOUNT(Usage_log[user_Id]),&lt;BR /&gt;ALL(Usage_log),&lt;BR /&gt;KEEPFILTERS(ALL('User_Categorization_Revised'[User_Type]))&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;IF (&lt;BR /&gt;WeekDate &amp;lt; FirstVisitDate || VisitorCount &amp;gt; 0,&lt;BR /&gt;VisitorCount,&lt;BR /&gt;BLANK()&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are the changes I made to your code:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;I adjusted the FirstVisitDate calculation to consider all rows in the 'Usage_log' table by using ALL('Usage_log').&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;I changed the condition in the IF statement. If WeekDate is less than FirstVisitDate, it checks if VisitorCount is greater than 0, and if so, it displays the visitor count; otherwise, it returns BLANK().&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;This DAX formula should give you the desired result. It will show bars for weeks with 0 visitors only if they come after the first week with visitors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 11:00:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Bar-chart-Avoiding-bars-without-value-with-an-condition/m-p/3498696#M134086</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2023-10-26T11:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Bar chart: Avoiding bars without value with an condition!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Bar-chart-Avoiding-bars-without-value-with-an-condition/m-p/3498741#M134091</link>
      <description>&lt;P&gt;Hello there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for your answer. However, I copied it but the result is now showing as following:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you be able to have a look? Thanks a lot!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Brenda&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 11:23:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Bar-chart-Avoiding-bars-without-value-with-an-condition/m-p/3498741#M134091</guid>
      <dc:creator>Yiyi_1989</dc:creator>
      <dc:date>2023-10-26T11:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: Bar chart: Avoiding bars without value with an condition!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Bar-chart-Avoiding-bars-without-value-with-an-condition/m-p/3498756#M134094</link>
      <description>&lt;P&gt;well, plz explain your issue.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 11:29:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Bar-chart-Avoiding-bars-without-value-with-an-condition/m-p/3498756#M134094</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2023-10-26T11:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: Bar chart: Avoiding bars without value with an condition!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Bar-chart-Avoiding-bars-without-value-with-an-condition/m-p/3498851#M134098</link>
      <description>&lt;P&gt;Thanks! So I used the following dax (based on the one you provided and did an adjustment in the end that if WeekDate &amp;gt;= FirstVisitDate, provide 0 instead.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue is that it still showed those weeks before the FirsitVisitDate as 0. I need to have them be blank().&amp;nbsp;I also checked the FiristVistDate and WeekDate separately and they seems to be correct.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;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 &amp;lt; FirstVisitDate || VisitorCount &amp;gt; 0,
VisitorCount,
0
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 12:10:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Bar-chart-Avoiding-bars-without-value-with-an-condition/m-p/3498851#M134098</guid>
      <dc:creator>Yiyi_1989</dc:creator>
      <dc:date>2023-10-26T12:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Bar chart: Avoiding bars without value with an condition!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Bar-chart-Avoiding-bars-without-value-with-an-condition/m-p/3498892#M134103</link>
      <description>&lt;P&gt;Now&amp;nbsp;&lt;SPAN&gt;I understand that you want to show blanks for weeks before the &lt;/SPAN&gt;FirstVisitDate&lt;SPAN&gt;. 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:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Visitors =&lt;BR /&gt;VAR FirstVisitDate = CALCULATE(MIN('Usage_log'[Date]), ALL('Usage_log'))&lt;BR /&gt;VAR WeekDate = SELECTEDVALUE(DateTable[StartDate])&lt;BR /&gt;VAR VisitorCount =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;DISTINCTCOUNT(Usage_log[user_Id]),&lt;BR /&gt;ALL(Usage_log),&lt;BR /&gt;KEEPFILTERS(ALL('User_Categorization_Revised'[User_Type]))&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;IF (&lt;BR /&gt;WeekDate &amp;lt; FirstVisitDate,&lt;BR /&gt;BLANK(),&lt;BR /&gt;IF(VisitorCount &amp;gt; 0, VisitorCount, BLANK())&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this modified formula, it explicitly returns BLANK() when WeekDate &amp;lt; FirstVisitDate, ensuring that weeks before the first visit date are left blank. Additionally, it checks for VisitorCount &amp;gt; 0 to decide whether to show the actual visitor count or a blank.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 12:26:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Bar-chart-Avoiding-bars-without-value-with-an-condition/m-p/3498892#M134103</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2023-10-26T12:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: Bar chart: Avoiding bars without value with an condition!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Bar-chart-Avoiding-bars-without-value-with-an-condition/m-p/3500562#M134210</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Great, now it works! Thank you so much for your help &lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt; &lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt; &amp;lt;3.&amp;nbsp;People like you make the community such a valuable place.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2023 06:13:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Bar-chart-Avoiding-bars-without-value-with-an-condition/m-p/3500562#M134210</guid>
      <dc:creator>Yiyi_1989</dc:creator>
      <dc:date>2023-10-27T06:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: Bar chart: Avoiding bars without value with an condition!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Bar-chart-Avoiding-bars-without-value-with-an-condition/m-p/3500610#M134218</link>
      <description>&lt;P&gt;You are always wellcome.&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2023 06:33:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Bar-chart-Avoiding-bars-without-value-with-an-condition/m-p/3500610#M134218</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2023-10-27T06:33:49Z</dc:date>
    </item>
  </channel>
</rss>

