<?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: Conditional Column Calculation Running Total in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conditional-Column-Calculation-Running-Total/m-p/1554766#M30786</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want it in DAX, you need in any case to add an Index column to the table in PQ to establish an order in the rows. Then you can create a calculated column:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Output =
VAR prevStart_ =
    CALCULATE (
        MAX ( Table1[Index] ),
        Table1[Start point] = 1,
        Table1[Index] &amp;lt; EARLIER ( Table1[Index] ),
        ALL ( Table1 )
    )
VAR prevEnd_ =
    CALCULATE (
        MAX ( Table1[Index] ),
        Table1[End point] = 1,
        Table1[Index] &amp;lt; EARLIER ( Table1[Index] ),
        ALL ( Table1 )
    )
RETURN
    IF ( prevStart_ &amp;gt; prevEnd_, 1, 0 )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;See it all at work in the attached file. Note I have left the column aux in the table.&amp;nbsp;You do not need it. It is just to&amp;nbsp; help understand what Output does.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Please mark the question solved when done and consider &lt;FONT color="#FF9900"&gt;giving a thumbs up if posts are helpful.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;Contact me privately for support with any larger-scale BI needs, tutoring, etc.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Cheers&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Dec 2020 19:19:40 GMT</pubDate>
    <dc:creator>AlB</dc:creator>
    <dc:date>2020-12-16T19:19:40Z</dc:date>
    <item>
      <title>Conditional Column Calculation Running Total</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conditional-Column-Calculation-Running-Total/m-p/1551603#M30698</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to set up a conditional running total in a string of numbers similar to my excel screenshot below. The output column will output a nonzero value once column A recoginises a Set point value of 1 (column 1) and keep counting until it sees the end point (column 2) value 1 again. I have this completed in excel, but I am struggling to do this in power bi as i cannot reference the previous row in the calculation column (output) similar to excel. I am trying to mimic this exactly in power bit, any help is appreciated&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2020 14:44:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conditional-Column-Calculation-Running-Total/m-p/1551603#M30698</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-12-15T14:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Column Calculation Running Total</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conditional-Column-Calculation-Running-Total/m-p/1552176#M30720</link>
      <description>&lt;P&gt;Hi Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could do this in DAX but it's probably best to do it in Power Query. Place the following M code in a blank query to see the steps. See it all at work in the attached file.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlDSAeJYHWSWIRYxVJYhTlkS9cYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Start point" = _t, #"End point" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Start point", Int64.Type}, {"End point", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    listStart_ = List.PositionOf(#"Added Index"[Start point], 1, Occurrence.All),
    listEnd_ = List.PositionOf(#"Added Index"[End point], 1, Occurrence.All),
    listT_ = List.Combine(List.Transform(List.Zip({listStart_, listEnd_}), each List.Numbers(_{0}+1,_{1}-_{0}))),
    listF_ = List.Transform(List.Numbers(0,Table.RowCount(#"Added Index")), each if List.Contains(listT_, _) then 1 else 0),
    final_ = Table.AddColumn(#"Added Index", "Output", each listF_{[Index]}),
    #"Removed Columns" = Table.RemoveColumns(final_,{"Index"})
in
    #"Removed Columns"&lt;/LI-CODE&gt;
&lt;P&gt;&lt;STRONG&gt;Please mark the question solved when done and consider &lt;FONT color="#FF9900"&gt;giving a thumbs up if posts are helpful.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;Contact me privately for support with any larger-scale BI needs, tutoring, etc.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Cheers&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;</description>
      <pubDate>Tue, 15 Dec 2020 20:34:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conditional-Column-Calculation-Running-Total/m-p/1552176#M30720</guid>
      <dc:creator>AlB</dc:creator>
      <dc:date>2020-12-15T20:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Column Calculation Running Total</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conditional-Column-Calculation-Running-Total/m-p/1554766#M30786</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want it in DAX, you need in any case to add an Index column to the table in PQ to establish an order in the rows. Then you can create a calculated column:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Output =
VAR prevStart_ =
    CALCULATE (
        MAX ( Table1[Index] ),
        Table1[Start point] = 1,
        Table1[Index] &amp;lt; EARLIER ( Table1[Index] ),
        ALL ( Table1 )
    )
VAR prevEnd_ =
    CALCULATE (
        MAX ( Table1[Index] ),
        Table1[End point] = 1,
        Table1[Index] &amp;lt; EARLIER ( Table1[Index] ),
        ALL ( Table1 )
    )
RETURN
    IF ( prevStart_ &amp;gt; prevEnd_, 1, 0 )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;See it all at work in the attached file. Note I have left the column aux in the table.&amp;nbsp;You do not need it. It is just to&amp;nbsp; help understand what Output does.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Please mark the question solved when done and consider &lt;FONT color="#FF9900"&gt;giving a thumbs up if posts are helpful.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;Contact me privately for support with any larger-scale BI needs, tutoring, etc.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Cheers&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2020 19:19:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conditional-Column-Calculation-Running-Total/m-p/1554766#M30786</guid>
      <dc:creator>AlB</dc:creator>
      <dc:date>2020-12-16T19:19:40Z</dc:date>
    </item>
  </channel>
</rss>

