<?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: Using end effective date and start effective date to count changes to individuals' scores in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-end-effective-date-and-start-effective-date-to-count/m-p/3231961#M118625</link>
    <description>&lt;P&gt;Hi ,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="415640" data-lia-user-login="sschumann" class="lia-mention lia-mention-user"&gt;sschumann&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your description, you want to "&lt;SPAN&gt;Using end effective date and start effective date to count changes to individuals' scores&lt;/SPAN&gt;".&lt;/P&gt;
&lt;P&gt;Here are the steps you can refer to :&lt;BR /&gt;(1)This is my test data:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;(2)We need to convert the table in Power Query Editor , you can put this M code in "Advanced Editor to refer to":&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtE3MtU3MjAyVtJBZSs8apis4JFfouCTmpgCFDAECsfqoGrAp85Q39ACpg6ZbQTW4Jyfn0NdHcjuMgbrCE8syqWuDhTd6B43MjbBCCBkNqY3wDpiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [startdate = _t, enddate = _t, score = _t, #"individual id" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"startdate", type date}, {"enddate", type date}, {"score", type text}, {"individual id", Int64.Type}}),
    #"Removed Duplicates" = Table.TransformColumns(Table.Distinct(#"Changed Type"),{"enddate",(x)=&amp;gt; if x=null then Date.From(DateTime.FixedLocalNow()) else x   }),
    #"Added Custom" = Table.AddColumn(#"Removed Duplicates", "Date", each if [startdate]=[enddate] then {[startdate]} else List.Dates(Date.AddDays( [startdate],1),Duration.Days(Duration.From([enddate]-Date.AddDays( [startdate],1)))  , #duration(1,0,0,0)    )),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"startdate", "enddate"}),
    #"Expanded Date" = Table.ExpandListColumn(#"Removed Columns", "Date"),
    #"Removed Duplicates1" = Table.Distinct(#"Expanded Date"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Removed Duplicates1",{{"Date", type date}}),
    Custom1 = Table.Group(#"Changed Type1","individual id",{"test",(x)=&amp;gt;Table.AddIndexColumn(Table.Sort(x,"Date"), "Index", 1, 1, Int64.Type)}),
    #"Expanded test" = Table.ExpandTableColumn(Custom1, "test", {"score", "Date", "Index"}, {"score", "Date", "Index"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Expanded test",{{"Date", type date}, {"Index", Int64.Type}, {"score", type text}}),
    #"Added Custom1" = Table.AddColumn(#"Changed Type2", "Custom", each Text.Start( [score] ,1)),
    #"Changed Type3" = Table.TransformColumnTypes(#"Added Custom1",{{"Custom", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type3",{{"Custom", "Score_Index"}})
in
    #"Renamed Columns"&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;(3)Then we need to create a table as dimension and we do not need to create any relationship between tables:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;(4)Then we can create a measure like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = var _cur_row = MAX('Table 2'[Index])
var _t2 = ADDCOLUMNS('Table' , "flag" , var _test =MAXX( FILTER('Table' , [Index]&amp;lt;EARLIER('Table'[Index])) ,[Score_Index]) return IF([Index]=1,0, IF([Score_Index] &amp;lt;&amp;gt; _test ,1,0)))
var _t3 = ADDCOLUMNS( _t2 , "Flag2" , var _falg = [flag]  var _test=MAXX( FILTER('Table' , [Index]&amp;lt;EARLIER('Table'[Index])) ,[Score_Index])  var _score = [Score_Index] return 
IF( _falg =1 , SWITCH(TRUE() , _test="2"&amp;amp;&amp;amp;_score="3",1,_test="2"&amp;amp;&amp;amp;_score="4",2,_test="4"&amp;amp;&amp;amp;_score="2",3,_test="4"&amp;amp;&amp;amp;_score="3",4,_test="3"&amp;amp;&amp;amp;_score="2",5,_test="3"&amp;amp;&amp;amp;_score="4",6)     , BLANK()))
return
COUNTROWS(FILTER(_t3 ,[Flag2] = _cur_row))
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then we can put the fields we need on the visual and we can get this:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this method does not meet your needs, you can provide us with your special &lt;STRONG&gt;sample data&lt;/STRONG&gt; and the &lt;STRONG&gt;desired output sample&lt;/STRONG&gt; data in the form of &lt;STRONG&gt;tables&lt;/STRONG&gt;, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )&lt;/P&gt;
&lt;P&gt;Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Aniya Zhang&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt; it as the solution&lt;/EM&gt;&amp;nbsp;to help the other members find it more quickly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 May 2023 02:20:28 GMT</pubDate>
    <dc:creator>v-yueyunzh-msft</dc:creator>
    <dc:date>2023-05-12T02:20:28Z</dc:date>
    <item>
      <title>Using end effective date and start effective date to count changes to individuals' scores</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-end-effective-date-and-start-effective-date-to-count/m-p/3229241#M118434</link>
      <description>&lt;P&gt;Its easiest if I start with an example of the data for one individual:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;startdate&lt;/TD&gt;&lt;TD&gt;enddate&lt;/TD&gt;&lt;TD&gt;score&lt;/TD&gt;&lt;TD&gt;individual id&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4/25/2023&lt;/TD&gt;&lt;TD&gt;4/25/2023&lt;/TD&gt;&lt;TD&gt;4 – Hot Lead&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4/25/2023&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;4 – Hot Lead&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/18/2023&lt;/TD&gt;&lt;TD&gt;1/18/2023&lt;/TD&gt;&lt;TD&gt;2 – Cool Lead&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/18/2023&lt;/TD&gt;&lt;TD&gt;1/18/2023&lt;/TD&gt;&lt;TD&gt;2 – Cool Lead&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/18/2023&lt;/TD&gt;&lt;TD&gt;4/25/2023&lt;/TD&gt;&lt;TD&gt;3 – Warm Lead&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/18/2023&lt;/TD&gt;&lt;TD&gt;4/25/2023&lt;/TD&gt;&lt;TD&gt;3 – Warm Lead&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to calculate the number of times individuals move from Cool-&amp;gt;Warm, Cool-&amp;gt;Hot, Warm-&amp;gt;Hot, Hot-&amp;gt;Warm, Hot-&amp;gt;Cool, Warm-&amp;gt;Cool. So for the individual 123, I want it to return 1 Cool-&amp;gt;Warm and 1 Warm-&amp;gt;Hot (happened on 1/18 and 4/25 for reference). The goal is aggregate all individuals to see how many times did sales people move them from A-&amp;gt;B in a given time period. Is there anyway to do this within DAX? Can I get a pointer to any dax command that might be useful here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Its all in an offprem powerbi dataset so I can use power query to transform if necessary...(Trying very hard not to rant about DAX)&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 17:27:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-end-effective-date-and-start-effective-date-to-count/m-p/3229241#M118434</guid>
      <dc:creator>sschumann</dc:creator>
      <dc:date>2023-05-10T17:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using end effective date and start effective date to count changes to individuals' scores</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-end-effective-date-and-start-effective-date-to-count/m-p/3231961#M118625</link>
      <description>&lt;P&gt;Hi ,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="415640" data-lia-user-login="sschumann" class="lia-mention lia-mention-user"&gt;sschumann&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your description, you want to "&lt;SPAN&gt;Using end effective date and start effective date to count changes to individuals' scores&lt;/SPAN&gt;".&lt;/P&gt;
&lt;P&gt;Here are the steps you can refer to :&lt;BR /&gt;(1)This is my test data:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;(2)We need to convert the table in Power Query Editor , you can put this M code in "Advanced Editor to refer to":&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtE3MtU3MjAyVtJBZSs8apis4JFfouCTmpgCFDAECsfqoGrAp85Q39ACpg6ZbQTW4Jyfn0NdHcjuMgbrCE8syqWuDhTd6B43MjbBCCBkNqY3wDpiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [startdate = _t, enddate = _t, score = _t, #"individual id" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"startdate", type date}, {"enddate", type date}, {"score", type text}, {"individual id", Int64.Type}}),
    #"Removed Duplicates" = Table.TransformColumns(Table.Distinct(#"Changed Type"),{"enddate",(x)=&amp;gt; if x=null then Date.From(DateTime.FixedLocalNow()) else x   }),
    #"Added Custom" = Table.AddColumn(#"Removed Duplicates", "Date", each if [startdate]=[enddate] then {[startdate]} else List.Dates(Date.AddDays( [startdate],1),Duration.Days(Duration.From([enddate]-Date.AddDays( [startdate],1)))  , #duration(1,0,0,0)    )),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"startdate", "enddate"}),
    #"Expanded Date" = Table.ExpandListColumn(#"Removed Columns", "Date"),
    #"Removed Duplicates1" = Table.Distinct(#"Expanded Date"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Removed Duplicates1",{{"Date", type date}}),
    Custom1 = Table.Group(#"Changed Type1","individual id",{"test",(x)=&amp;gt;Table.AddIndexColumn(Table.Sort(x,"Date"), "Index", 1, 1, Int64.Type)}),
    #"Expanded test" = Table.ExpandTableColumn(Custom1, "test", {"score", "Date", "Index"}, {"score", "Date", "Index"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Expanded test",{{"Date", type date}, {"Index", Int64.Type}, {"score", type text}}),
    #"Added Custom1" = Table.AddColumn(#"Changed Type2", "Custom", each Text.Start( [score] ,1)),
    #"Changed Type3" = Table.TransformColumnTypes(#"Added Custom1",{{"Custom", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type3",{{"Custom", "Score_Index"}})
in
    #"Renamed Columns"&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;(3)Then we need to create a table as dimension and we do not need to create any relationship between tables:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;(4)Then we can create a measure like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = var _cur_row = MAX('Table 2'[Index])
var _t2 = ADDCOLUMNS('Table' , "flag" , var _test =MAXX( FILTER('Table' , [Index]&amp;lt;EARLIER('Table'[Index])) ,[Score_Index]) return IF([Index]=1,0, IF([Score_Index] &amp;lt;&amp;gt; _test ,1,0)))
var _t3 = ADDCOLUMNS( _t2 , "Flag2" , var _falg = [flag]  var _test=MAXX( FILTER('Table' , [Index]&amp;lt;EARLIER('Table'[Index])) ,[Score_Index])  var _score = [Score_Index] return 
IF( _falg =1 , SWITCH(TRUE() , _test="2"&amp;amp;&amp;amp;_score="3",1,_test="2"&amp;amp;&amp;amp;_score="4",2,_test="4"&amp;amp;&amp;amp;_score="2",3,_test="4"&amp;amp;&amp;amp;_score="3",4,_test="3"&amp;amp;&amp;amp;_score="2",5,_test="3"&amp;amp;&amp;amp;_score="4",6)     , BLANK()))
return
COUNTROWS(FILTER(_t3 ,[Flag2] = _cur_row))
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then we can put the fields we need on the visual and we can get this:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this method does not meet your needs, you can provide us with your special &lt;STRONG&gt;sample data&lt;/STRONG&gt; and the &lt;STRONG&gt;desired output sample&lt;/STRONG&gt; data in the form of &lt;STRONG&gt;tables&lt;/STRONG&gt;, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )&lt;/P&gt;
&lt;P&gt;Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Aniya Zhang&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt; it as the solution&lt;/EM&gt;&amp;nbsp;to help the other members find it more quickly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 02:20:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-end-effective-date-and-start-effective-date-to-count/m-p/3231961#M118625</guid>
      <dc:creator>v-yueyunzh-msft</dc:creator>
      <dc:date>2023-05-12T02:20:28Z</dc:date>
    </item>
  </channel>
</rss>

