<?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 Build a graph with specific conditions in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Build-a-graph-with-specific-conditions/m-p/3710016#M144351</link>
    <description>&lt;P&gt;Suppose I have the table below.&lt;BR /&gt;I want a graph where on the Y axis, we have the number of Num and on the X axis, the dates in days and months &lt;STRONG&gt;(Table[date])&lt;/STRONG&gt;. The graph will count the number of Num &lt;STRONG&gt;(Table[Num])&lt;/STRONG&gt; where the color is different from "black".&lt;/P&gt;&lt;P&gt;Also, there are the following conditions:&lt;BR /&gt;&lt;STRONG&gt;1-&lt;/STRONG&gt;months and days must only be those of the last 7 days from Today()&lt;BR /&gt;&lt;STRONG&gt;2-&lt;/STRONG&gt;Also, if a date OF THE LAST 7 DAYS does not exist&amp;nbsp;in the table[date], this date should be displayed, but with the number of Num must be 0. (for example, because 2024-02-18 do not appear in the table[date], but&amp;nbsp;it is part of the last 7 days from today, it must be displayed, and in the Axis Y, the value must be 0.&lt;BR /&gt;&lt;STRONG&gt;3-&lt;/STRONG&gt;If on a specific date, we just have a color "black", the number of Num must also be 0.&lt;/P&gt;&lt;P&gt;So, for the last 7 days, I want the intervall of &lt;STRONG&gt;2024-02-13 to 2024-02-19.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Feb 2024 06:51:53 GMT</pubDate>
    <dc:creator>game1</dc:creator>
    <dc:date>2024-02-20T06:51:53Z</dc:date>
    <item>
      <title>Build a graph with specific conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Build-a-graph-with-specific-conditions/m-p/3710016#M144351</link>
      <description>&lt;P&gt;Suppose I have the table below.&lt;BR /&gt;I want a graph where on the Y axis, we have the number of Num and on the X axis, the dates in days and months &lt;STRONG&gt;(Table[date])&lt;/STRONG&gt;. The graph will count the number of Num &lt;STRONG&gt;(Table[Num])&lt;/STRONG&gt; where the color is different from "black".&lt;/P&gt;&lt;P&gt;Also, there are the following conditions:&lt;BR /&gt;&lt;STRONG&gt;1-&lt;/STRONG&gt;months and days must only be those of the last 7 days from Today()&lt;BR /&gt;&lt;STRONG&gt;2-&lt;/STRONG&gt;Also, if a date OF THE LAST 7 DAYS does not exist&amp;nbsp;in the table[date], this date should be displayed, but with the number of Num must be 0. (for example, because 2024-02-18 do not appear in the table[date], but&amp;nbsp;it is part of the last 7 days from today, it must be displayed, and in the Axis Y, the value must be 0.&lt;BR /&gt;&lt;STRONG&gt;3-&lt;/STRONG&gt;If on a specific date, we just have a color "black", the number of Num must also be 0.&lt;/P&gt;&lt;P&gt;So, for the last 7 days, I want the intervall of &lt;STRONG&gt;2024-02-13 to 2024-02-19.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 06:51:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Build-a-graph-with-specific-conditions/m-p/3710016#M144351</guid>
      <dc:creator>game1</dc:creator>
      <dc:date>2024-02-20T06:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: Build a graph with specific conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Build-a-graph-with-specific-conditions/m-p/3710168#M144356</link>
      <description>&lt;OL&gt;&lt;LI&gt;Create a new calculated table or measure that generates the date range for the last 7 days from today.&lt;/LI&gt;&lt;LI&gt;Use DAX to calculate the count of Num where the color is different from "black" for each date in the last 7 days.&lt;/LI&gt;&lt;LI&gt;Handle cases where a date does not exist in the table[date] and where the color is "black".&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Here's how you can achieve this:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Calculate the Date Range for the Last 7 Days:&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Last7Days =&lt;BR /&gt;VAR TodayDate = TODAY()&lt;BR /&gt;RETURN&lt;BR /&gt;FILTER(&lt;BR /&gt;CALENDAR(TODAY() - 6, TODAY()),&lt;BR /&gt;[Date] &amp;lt;= TodayDate&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Calculate the Count of Num for Each Date:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;NumCount =&lt;BR /&gt;VAR Last7Days = CALCULATETABLE(Last7Days, ALL(Table))&lt;BR /&gt;RETURN&lt;BR /&gt;ADDCOLUMNS(&lt;BR /&gt;Last7Days,&lt;BR /&gt;"NumCount",&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTROWS(Table),&lt;BR /&gt;Table[color] &amp;lt;&amp;gt; "black",&lt;BR /&gt;Table[date] = [Date]&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Handle Cases Where a Date Does Not Exist or Color is "black":&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;NumCount =&lt;BR /&gt;VAR Last7Days = CALCULATETABLE(Last7Days, ALL(Table))&lt;BR /&gt;RETURN&lt;BR /&gt;ADDCOLUMNS(&lt;BR /&gt;Last7Days,&lt;BR /&gt;"NumCount",&lt;BR /&gt;IF(&lt;BR /&gt;ISBLANK(&lt;BR /&gt;LOOKUPVALUE(&lt;BR /&gt;Table[Num],&lt;BR /&gt;Table[date], [Date]&lt;BR /&gt;)&lt;BR /&gt;),&lt;BR /&gt;0,&lt;BR /&gt;IF(&lt;BR /&gt;LOOKUPVALUE(&lt;BR /&gt;Table[color],&lt;BR /&gt;Table[date], [Date]&lt;BR /&gt;) = "black",&lt;BR /&gt;0,&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTROWS(Table),&lt;BR /&gt;Table[color] &amp;lt;&amp;gt; "black",&lt;BR /&gt;Table[date] = [Date]&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Once you have these measures or calculated tables, you can use them to create a line or bar graph where the X-axis is the date and the Y-axis is the NumCount. Make sure to use the NumCount measure as the values for your graph.&lt;/SPAN&gt;&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>Tue, 20 Feb 2024 07:49:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Build-a-graph-with-specific-conditions/m-p/3710168#M144356</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2024-02-20T07:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: Build a graph with specific conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Build-a-graph-with-specific-conditions/m-p/3713035#M144482</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have try it, but it is not working verry well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 04:49:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Build-a-graph-with-specific-conditions/m-p/3713035#M144482</guid>
      <dc:creator>game1</dc:creator>
      <dc:date>2024-02-21T04:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Build a graph with specific conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Build-a-graph-with-specific-conditions/m-p/3713172#M144492</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="659758" data-lia-user-login="game1" class="lia-mention lia-mention-user"&gt;game1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your description, here are my steps you can follow as a solution.&lt;/P&gt;
&lt;P&gt;(1) My test data is the same as yours.&lt;/P&gt;
&lt;P&gt;(2) We can create a date table.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;DateTable = CALENDAR(DATE(2024,1,1),DATE(2024,12,31))&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;(3) We can create measures.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
var _a= COUNTROWS(FILTER(ALL('Table'),'Table'[Date]=MAX('Table'[Date]) &amp;amp;&amp;amp; 'Table'[Color] &amp;lt;&amp;gt; "black"))
RETURN IF(_a=BLANK(),0,_a)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Flag = IF(MAX('DateTable'[Date])&amp;lt;=TODAY() &amp;amp;&amp;amp; MAX('DateTable'[Date]) &amp;gt;=TODAY()-6,1,0) &lt;/LI-CODE&gt;
&lt;P&gt;(4) Place [Flag=1] on the visual object screening and then the result is as follows.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;If the above one can't help you get the desired result, please provide some&amp;nbsp;&lt;STRONG&gt;sample data&lt;/STRONG&gt;&amp;nbsp;in your tables (&lt;STRONG&gt;exclude&amp;nbsp;sensitive&amp;nbsp;data&lt;/STRONG&gt;) with&amp;nbsp;&lt;STRONG&gt;Text&lt;/STRONG&gt;&amp;nbsp;format and your&amp;nbsp;&lt;STRONG&gt;expected result&lt;/STRONG&gt;&amp;nbsp;with backend logic and special examples.&amp;nbsp;&lt;STRONG&gt;It is better&lt;/STRONG&gt;&amp;nbsp;if you can share a&amp;nbsp;&lt;STRONG&gt;simplified&lt;/STRONG&gt;&amp;nbsp;pbix file.&amp;nbsp;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Neeko Tang&lt;/P&gt;
&lt;P&gt;If this post  &lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accept it as the solution &lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 05:54:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Build-a-graph-with-specific-conditions/m-p/3713172#M144492</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-02-21T05:54:36Z</dc:date>
    </item>
  </channel>
</rss>

