<?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: SQL / Power Query recursive - From Startdate to 12 month filled timespan in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/SQL-Power-Query-recursive-From-Startdate-to-12-month-filled/m-p/4661435#M60615</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/664278"&gt;@Do57792&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&lt;SPAN data-teams="true"&gt;I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please &lt;STRONG&gt;accept it as a solution&lt;/STRONG&gt; and give a &lt;STRONG&gt;'Kudos'&lt;/STRONG&gt; so other members can easily find it.&lt;BR /&gt;&lt;BR /&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Apr 2025 14:33:06 GMT</pubDate>
    <dc:creator>V-yubandi-msft</dc:creator>
    <dc:date>2025-04-21T14:33:06Z</dc:date>
    <item>
      <title>SQL / Power Query recursive - From Startdate to 12 month filled timespan</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/SQL-Power-Query-recursive-From-Startdate-to-12-month-filled/m-p/4605623#M59799</link>
      <description>&lt;P&gt;Hello experts !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this is at the right part of the forum.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table with project costs. The projects are clearly numbered. There is also a column with the start date and costs. (Very simplified). The costs are distributed over 12 months starting from the start date. In some cases the costs differ and are not total costs divided by 12.&lt;/P&gt;&lt;P&gt;I would like to have an overview table that shows the projects, the months and the amount for the month to make it easier in Power Bi and not have to map everything via Dax:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Origin data:&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Project&lt;/TD&gt;&lt;TD&gt;Startdate&lt;/TD&gt;&lt;TD&gt;Costs&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;01 Jan 2025&lt;/TD&gt;&lt;TD&gt;120&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;07 Sep 2020&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;09 Oct 2021&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Target&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Project&lt;/TD&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Partly Costs&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Jan 2025&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Feb 2025&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Mar 2025&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Dec 2025&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Sep 2020&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Oct2020&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Aug 2020&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;The first idea was to map this using SQL and CTE.&lt;BR /&gt;Unfortunately I failed here. Is CTE supported at all? Within the interval, the plan was to use case queries to change the costs per property of the projects if necessary. I didn't get that far, because not even the body outputs the values accordingly.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;WITH RECURSIVE months as (
    -- Basis: Startmonat (Monat 0)
    SELECT 

        Project,
        Costs,
        Startdate AS month_date,
        Costs/ 12.0 AS monthly_costs,
        0 AS month_number
    FROM Projects
    
    UNION ALL
    
    SELECT 
        Project,
        Costs,
        DATEADD(month,  1, Startdate) AS month_date,
        monthly_costs,
        month_number + 1
    FROM months
    WHERE month_number &amp;lt; 11 
)



SELECT 
    Project,
    month_date AS 'Month',
    monthly_costs AS 'Monthly Costs'
FROM months
ORDER BY Project, month_date&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Is it necessary and also possible to map something like this via Power Query and if so, is there a corresponding guideline?&lt;/P&gt;&lt;P&gt;Many thanks in advance for any help.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Mar 2025 18:25:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/SQL-Power-Query-recursive-From-Startdate-to-12-month-filled/m-p/4605623#M59799</guid>
      <dc:creator>Do57792</dc:creator>
      <dc:date>2025-03-11T18:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: SQL / Power Query recursive - From Startdate to 12 month filled timespan</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/SQL-Power-Query-recursive-From-Startdate-to-12-month-filled/m-p/4605811#M59802</link>
      <description>&lt;P&gt;On the CTE part, what SQL engine are you using? that is going to determine if recursion is supported.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to use powerquery&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIwVPBKzFMwMjAyBfIMjQyUYnWilYxAMuYKwakFIBkDsAxYwhgkYangn1wCkgAZYAbUEQsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Project = _t, Startdate = _t, Costs = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Project", Int64.Type}, {"Startdate", type date}, {"Costs", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "months", each 
List.Generate(() =&amp;gt; 0, each _ &amp;lt; 12, each _ + 1)),
    #"Expanded 12 months" = Table.ExpandListColumn(#"Added Custom", "months"),
    #"Added Custom1" = Table.AddColumn(#"Expanded 12 months", "Dates", each Date.AddMonths([Startdate], [months])),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Partly Costs", each [Costs] / 12),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Costs", "months"})
in
    #"Removed Columns"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Mar 2025 22:09:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/SQL-Power-Query-recursive-From-Startdate-to-12-month-filled/m-p/4605811#M59802</guid>
      <dc:creator>Deku</dc:creator>
      <dc:date>2025-03-11T22:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: SQL / Power Query recursive - From Startdate to 12 month filled timespan</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/SQL-Power-Query-recursive-From-Startdate-to-12-month-filled/m-p/4648064#M60347</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/664278"&gt;@Do57792&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;May I ask if you have resolved this issue? If so, please mark the helpful reply and &lt;STRONG&gt;accept it as the solution.&lt;/STRONG&gt; This will be helpful for other community members who have similar problems to solve it faster.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2025 06:32:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/SQL-Power-Query-recursive-From-Startdate-to-12-month-filled/m-p/4648064#M60347</guid>
      <dc:creator>V-yubandi-msft</dc:creator>
      <dc:date>2025-04-11T06:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: SQL / Power Query recursive - From Startdate to 12 month filled timespan</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/SQL-Power-Query-recursive-From-Startdate-to-12-month-filled/m-p/4661435#M60615</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/664278"&gt;@Do57792&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&lt;SPAN data-teams="true"&gt;I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please &lt;STRONG&gt;accept it as a solution&lt;/STRONG&gt; and give a &lt;STRONG&gt;'Kudos'&lt;/STRONG&gt; so other members can easily find it.&lt;BR /&gt;&lt;BR /&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Apr 2025 14:33:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/SQL-Power-Query-recursive-From-Startdate-to-12-month-filled/m-p/4661435#M60615</guid>
      <dc:creator>V-yubandi-msft</dc:creator>
      <dc:date>2025-04-21T14:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: SQL / Power Query recursive - From Startdate to 12 month filled timespan</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/SQL-Power-Query-recursive-From-Startdate-to-12-month-filled/m-p/4667982#M60785</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/664278"&gt;@Do57792&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;We noticed we haven't received a response from you yet, so we wanted to follow up and ensure the solution we provided addressed your issue. If you require any further assistance or have additional questions, please let us know.&lt;/P&gt;
&lt;P&gt;Your feedback is valuable to us, and we look forward to hearing from you soon.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Apr 2025 07:33:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/SQL-Power-Query-recursive-From-Startdate-to-12-month-filled/m-p/4667982#M60785</guid>
      <dc:creator>V-yubandi-msft</dc:creator>
      <dc:date>2025-04-25T07:33:20Z</dc:date>
    </item>
  </channel>
</rss>

