<?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 Re: Create a Flag measure based on Start date and End Date. in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-Flag-measure-based-on-Start-date-and-End-Date/m-p/3183443#M115166</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&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 measure.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Flag = 
Var startdate=SELECTEDVALUE('Selection Values'[CAL_DT])
var Startdate_plus = startdate+1
Var PStrt_date= startdate-365
var enddate= startdate+14
var _sdate=IF(MAX('Fact'[STATUS_ID]) in {"A501","A405","A411"},PStrt_date,Startdate_plus)
return 
IF(MAX('Fact'[CAL_DT])&amp;gt;=_sdate &amp;amp;&amp;amp; MAX('Fact'[CAL_DT])&amp;lt;=enddate,1,0)&lt;/LI-CODE&gt;
&lt;P&gt;(3) Then the result is as follows.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&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;helps&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, 12 Apr 2023 07:57:18 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-04-12T07:57:18Z</dc:date>
    <item>
      <title>Create a Flag measure based on Start date and End Date.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-Flag-measure-based-on-Start-date-and-End-Date/m-p/3176403#M114675</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;I have a table and I need to show records between start date and End date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Need to create a flag which has to be 1 for dates which is between start date and End Date. So that I can drop flag in measure and select "1" to show the records.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the Dax I used but gettting error "Multiple Values supplied instead of one"&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;Flag = &lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;Var startdate=SELECTEDVALUE('Selection Values'[CAL_DT])&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;var Startdate_plus = startdate+1&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;Var PStrt_date= startdate-365&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;var enddate= startdate+&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt;14&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;return IF(AND(VALUES(V_DAILY_SERVICE_CALL_LOG[CAL_DT]) &amp;gt;= IF(VALUES(V_DAILY_SERVICE_CALL_LOG[STATUS_ID]) IN {"A501","A405","A411"},PStrt_date,Startdate_plus),VALUES(V_DAILY_SERVICE_CALL_LOG[CAL_DT]) &amp;lt;= enddate),1,0&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Here&amp;nbsp;(V_DAILY_SERVICE_CALL_LOG[CAL_DT] is retireved by using lookup from date table.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Below is the model:&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;My fact table is &lt;SPAN&gt;&lt;STRONG&gt;V_DAILY_SERVICE_CALL_LOG. &lt;/STRONG&gt;Date slicer is coming from a separate table which is not in relation with Fact table and Service dest is coming from a Dimension table which is in One to Many relation with Fact.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Relative SQL query for flag is below, I want to convert that Flag query to Flag measure so that I can drop this to Table Vizualization filter pane:-&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;Select * from(&lt;BR /&gt;Select f.*,&lt;BR /&gt;CASE When d.CAL_DT BETWEEN (CASE WHEN STATUS_ID IN ('A501','A405','A411') THEN DATEADD(DAY,-365,'2023-03-04') ELSE DATEADD(DAY,1,'2023-03-04') END) AND DATEADD(DAY,14,'2023-03-04') THEN 1 ELSE 0 END as Flag&lt;BR /&gt;from "LESL_DW_UAT"."PBI_MART"."V_DAILY_SERVICE_CALL_LOG" f&lt;BR /&gt;inner join "LESL_DW_UAT"."PBI_MART"."V_DATE_DIM" d on f.DT_SKEY = d.DT_SKEY&lt;BR /&gt;inner join "LESL_DW_UAT"."PBI_MART"."V_STORE_SERVICE_DIM" s on f.STORE_KEY = s.STORE_KEY&lt;BR /&gt;where&lt;BR /&gt;s.SERVICE_DSTRCT_CD ='22' ) A where Flag = 1&lt;/STRONG&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 06 Apr 2023 16:49:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-Flag-measure-based-on-Start-date-and-End-Date/m-p/3176403#M114675</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-04-06T16:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Flag measure based on Start date and End Date.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-Flag-measure-based-on-Start-date-and-End-Date/m-p/3178435#M114842</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any chance you can share your pbix (or at least a smaller sample version)?&lt;/P&gt;</description>
      <pubDate>Sat, 08 Apr 2023 13:29:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-Flag-measure-based-on-Start-date-and-End-Date/m-p/3178435#M114842</guid>
      <dc:creator>Wilson_</dc:creator>
      <dc:date>2023-04-08T13:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Flag measure based on Start date and End Date.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-Flag-measure-based-on-Start-date-and-End-Date/m-p/3183256#M115143</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&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) This is my test data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;(2) We can create a measure.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Flag = 
var _startdate=CALCULATE(MAX('Selection Values'[CAL_DT]),FILTER(ALL('Selection Values'),'Selection Values'[STATUS_ID]=MAX('V_DAILY_SERVICE_CALL_LOG'[STATUS_ID])))
var _enddate=_startdate+14
var _flag=IF(SELECTEDVALUE('V_DAILY_SERVICE_CALL_LOG'[CAL_DT])&amp;gt;=_startdate &amp;amp;&amp;amp; SELECTEDVALUE(V_DAILY_SERVICE_CALL_LOG[CAL_DT])&amp;lt;=_enddate,1,0)
return _flag&lt;/LI-CODE&gt;
&lt;P&gt;(3) Then the result is as follows.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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;helps&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, 12 Apr 2023 05:59:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-Flag-measure-based-on-Start-date-and-End-Date/m-p/3183256#M115143</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-04-12T05:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Flag measure based on Start date and End Date.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-Flag-measure-based-on-Start-date-and-End-Date/m-p/3183375#M115154</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the response.&lt;BR /&gt;In my case, There are two conditions&lt;/P&gt;&lt;P&gt;&amp;nbsp;date between status_id in&amp;nbsp;&lt;STRONG&gt;('A501','A405','A411') &lt;/STRONG&gt;then &lt;STRONG&gt;start_date -365&lt;/STRONG&gt; else &lt;STRONG&gt;start_date+1&lt;/STRONG&gt; and End_date.&lt;/P&gt;&lt;P&gt;I added a sample pbix. please download pbix with sample data.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://drive.google.com/file/d/1l17xTVn0iPwSZfB_mODdcljxKwf0dAVY/view?usp=share_link" target="_blank"&gt;https://drive.google.com/file/d/1l17xTVn0iPwSZfB_mODdcljxKwf0dAVY/view?usp=share_link&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 07:06:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-Flag-measure-based-on-Start-date-and-End-Date/m-p/3183375#M115154</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-04-12T07:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Flag measure based on Start date and End Date.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-Flag-measure-based-on-Start-date-and-End-Date/m-p/3183378#M115155</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="540281" data-lia-user-login="Wilson_" class="lia-mention lia-mention-user"&gt;Wilson_&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/file/d/1l17xTVn0iPwSZfB_mODdcljxKwf0dAVY/view?usp=share_link" target="_blank" rel="nofollow noopener noreferrer"&gt;https://drive.google.com/file/d/1l17xTVn0iPwSZfB_mODdcljxKwf0dAVY/view?usp=share_link&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Please find the attched pbix&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 07:07:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-Flag-measure-based-on-Start-date-and-End-Date/m-p/3183378#M115155</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-04-12T07:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Flag measure based on Start date and End Date.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-Flag-measure-based-on-Start-date-and-End-Date/m-p/3183443#M115166</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&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 measure.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Flag = 
Var startdate=SELECTEDVALUE('Selection Values'[CAL_DT])
var Startdate_plus = startdate+1
Var PStrt_date= startdate-365
var enddate= startdate+14
var _sdate=IF(MAX('Fact'[STATUS_ID]) in {"A501","A405","A411"},PStrt_date,Startdate_plus)
return 
IF(MAX('Fact'[CAL_DT])&amp;gt;=_sdate &amp;amp;&amp;amp; MAX('Fact'[CAL_DT])&amp;lt;=enddate,1,0)&lt;/LI-CODE&gt;
&lt;P&gt;(3) Then the result is as follows.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&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;helps&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, 12 Apr 2023 07:57:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-Flag-measure-based-on-Start-date-and-End-Date/m-p/3183443#M115166</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-04-12T07:57:18Z</dc:date>
    </item>
  </channel>
</rss>

