<?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: Sumifs with variable selection in Power Query</title>
    <link>https://community.fabric.microsoft.com/t5/Power-Query/Sumifs-with-variable-selection/m-p/2027069#M59639</link>
    <description>&lt;P&gt;You may need to "unlearn"&amp;nbsp; some of your Excel knowledge, and embrace Power Query's way of thinking.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide sample data in usable format (not as a picture - maybe insert into a table?) and show the expected outcome.&lt;/P&gt;</description>
    <pubDate>Fri, 20 Aug 2021 00:38:23 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2021-08-20T00:38:23Z</dc:date>
    <item>
      <title>Sumifs with variable selection</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Sumifs-with-variable-selection/m-p/2024369#M59563</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to this forum and to Power Query.&lt;/P&gt;&lt;P&gt;My name is Stefano and I am a quite proficient excel users which is trying ti migrate to expand his knowledge to Power Query and Power BI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have recently created a an excel file which, give date, time of day and operating times, generates a normal distribution to split a daily volume into hourly components.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did so in a table thorugh the use of&amp;nbsp;NORM.DIST function and some support columns.&lt;/P&gt;&lt;P&gt;below a visual example:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have progress in creating a query up to column "Hours Trading".&lt;/P&gt;&lt;P&gt;I am currently stuck in creating the "Marker" column, in excel I have used the below formula:&lt;/P&gt;&lt;P&gt;=IF([@[Hours Trading]]=0,"",SUMIFS(&lt;STRONG&gt;$F$7:$F7,$A$7:$A7&lt;/STRONG&gt;,[@Date],&lt;STRONG&gt;$C$7:$C7&lt;/STRONG&gt;,C7))&lt;/P&gt;&lt;P&gt;the arguments in bold expand as the formula is dragged down the table.&lt;/P&gt;&lt;P&gt;The intention is to create a increasing value for each hour in which the store will be trading.&lt;/P&gt;&lt;P&gt;If on 1/01/2021 at 8:00 the store is trading and is the first hour of trade return 1, at 9:00 would return 2, and so on until the last hour of the trade of the day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know how to achieve the above in Power Query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;on a more general note:&lt;/P&gt;&lt;P&gt;the columns "Marker", "Median" and "Standard Deviation" are then used to generate a "Standard Distribution" which is refined to be always 100% across the day.&lt;/P&gt;&lt;P&gt;"Median" is simply the average of all "Marker" Values and "Standard Deviation" is taken from an additional table which i setup manually according to the values which give me the best shape of the bell curve.&lt;/P&gt;&lt;P&gt;The ultimate goal is to achieve a query that automatically generates a standard distribution between the times trade which are an input from a table in excel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone help me in achieving this end result and explain me how to do it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;below the code from the advanced editor of what achieved so far in my query:&lt;/P&gt;&lt;P&gt;let&lt;BR /&gt;Source = Table.NestedJoin(Date, {"Local Key"}, Time, {"Local Key"}, "Time", JoinKind.LeftOuter),&lt;BR /&gt;#"Expanded Time" = Table.ExpandTableColumn(Source, "Time", {"Time"}, {"Time.Time"}),&lt;BR /&gt;#"Merged Queries" = Table.NestedJoin(#"Expanded Time", {"Local Key"}, Store, {"Local Key"}, "Store", JoinKind.LeftOuter),&lt;BR /&gt;#"Expanded Store" = Table.ExpandTableColumn(#"Merged Queries", "Store", {"Store"}, {"Store.Store"}),&lt;BR /&gt;#"Renamed Columns" = Table.RenameColumns(#"Expanded Store",{{"Time.Time", "Time"}, {"Store.Store", "Store"}}),&lt;BR /&gt;#"Merged Queries1" = Table.NestedJoin(#"Renamed Columns", {"Date", "Store"}, Store_Trading_Times, {"Date", "Store"}, "Store_Trading_Times", JoinKind.LeftOuter),&lt;BR /&gt;#"Expanded Store_Trading_Times" = Table.ExpandTableColumn(#"Merged Queries1", "Store_Trading_Times", {"Open Trade", "Close Trade"}, {"Store_Trading_Times.Open Trade", "Store_Trading_Times.Close Trade"}),&lt;BR /&gt;#"Renamed Columns1" = Table.RenameColumns(#"Expanded Store_Trading_Times",{{"Store_Trading_Times.Open Trade", "Open Trade"}, {"Store_Trading_Times.Close Trade", "Close Trade"}}),&lt;BR /&gt;#"Added Custom" = Table.AddColumn(#"Renamed Columns1", "Hours Trading", each if[Time]&amp;gt;=[Open Trade] and [Time]&amp;lt;[Close Trade] then 1 else 0),&lt;BR /&gt;#"Filtered Rows" = Table.SelectRows(#"Added Custom", each true)&lt;BR /&gt;in&lt;BR /&gt;#"Filtered Rows"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Stefano&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 09:41:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Sumifs-with-variable-selection/m-p/2024369#M59563</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-08-19T09:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: Sumifs with variable selection</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Sumifs-with-variable-selection/m-p/2027069#M59639</link>
      <description>&lt;P&gt;You may need to "unlearn"&amp;nbsp; some of your Excel knowledge, and embrace Power Query's way of thinking.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide sample data in usable format (not as a picture - maybe insert into a table?) and show the expected outcome.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 00:38:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Sumifs-with-variable-selection/m-p/2027069#M59639</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2021-08-20T00:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: Sumifs with variable selection</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Sumifs-with-variable-selection/m-p/2034331#M59865</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;I completed it in Power Query, you can download the attachment to view the details.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I recommend you to create calculated columns in Power BI Desktop, which is easier.&amp;nbsp;You can also check it in the attachment.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Marker calculated column = IF([Time]&amp;lt;[End Trading]&amp;amp;&amp;amp;[Time]&amp;gt;=[Start Trading],RANKX(FILTER('Table',[Date]=EARLIER('Table'[Date])),'Table'[Time],,ASC,Dense)-HOUR([Start Trading]))&lt;/LI-CODE&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;Stephen Tao&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 08:14:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Sumifs-with-variable-selection/m-p/2034331#M59865</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-08-24T08:14:03Z</dc:date>
    </item>
  </channel>
</rss>

