Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
RichaBansal
Frequent Visitor

the number of times unpivoting a row

Hi PBI Experts,

 

RichaBansal_0-1712061812129.png

 

Can we achieve this?

 

Many many thanks in advance.

2 ACCEPTED SOLUTIONS
Joe_Barry
Solution Sage
Solution Sage

Hi @RichaBansal 

 

With that exact data no, but if the Start and End Columns were formated as dates, then yes.

 

  • Add a custom column  to create month amount between dates

 

Date.Year([End])*12+Date.Month([End])-Date.Year([Start])*12-Date.Month([Start])​

 

  • Create a column to calculate Monthly Amount

 

[Amount]/ [Custom]​

 

  • Create another column called "Intervals" 

 

List.Numbers(1,[Custom])​

 

  • Then add another to create the months 

 

Date.StartOfMonth(
  Date.AddMonths(
    [Start],
    [Intervals] -1
  )
))​

 

This should help

Joe

 

If you found my answer helpful and it solved your issue, please accept as solution




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn


Let's connect on LinkedIn


View solution in original post

I think I missed a step. You will need to expand the list to new rows before adding the last step




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn


Let's connect on LinkedIn


View solution in original post

6 REPLIES 6
Joe_Barry
Solution Sage
Solution Sage

Hi @RichaBansal 

 

With that exact data no, but if the Start and End Columns were formated as dates, then yes.

 

  • Add a custom column  to create month amount between dates

 

Date.Year([End])*12+Date.Month([End])-Date.Year([Start])*12-Date.Month([Start])​

 

  • Create a column to calculate Monthly Amount

 

[Amount]/ [Custom]​

 

  • Create another column called "Intervals" 

 

List.Numbers(1,[Custom])​

 

  • Then add another to create the months 

 

Date.StartOfMonth(
  Date.AddMonths(
    [Start],
    [Intervals] -1
  )
))​

 

This should help

Joe

 

If you found my answer helpful and it solved your issue, please accept as solution




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn


Let's connect on LinkedIn


Hi Joe,

 

The start and end are dates. I got the list of numbers, but the Last column shows error.

RichaBansal_1-1712131774661.png

 

 

I think I missed a step. You will need to expand the list to new rows before adding the last step




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn


Let's connect on LinkedIn


Worked like a charm 🙂

Thank you Joe. Have a pleasant day.

dufoq3
Community Champion
Community Champion

This will work only in case when Start and End are defined as dates. @RichaBansal, let us know if input Start and End are dates or just text "Jan" and "April"


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

dufoq3
Community Champion
Community Champion

@RichaBansal, in case you have input stored as text, try this:

 

Result:

dufoq3_1-1712067284989.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8krMU9JRciwoyswB0oYGIKAUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Start = _t, End = _t, Amount = _t]),
    Transformed = Table.TransformColumns(Source, {
        {"Start", each Date.Month(Date.FromText("2024" & Text.Start(_,3) & "01", [Format="yyyyMMMdd", Culture="en-US"])), Int64.Type},
        {"End", each Date.Month(Date.FromText("2024" & Text.Start(_,3) & "01", [Format="yyyyMMMdd", Culture="en-US"])), Int64.Type},
        {"Amount", Number.From, type number}
}),
    Ad_FinalTable = Table.AddColumn(Transformed, "FinalTable", each 
        [ a = [Amount] / ([End]-[Start]+1),
          b = List.Transform({[Start]..[End]}, (x)=> Date.ToText(#date(2024,x,1), "MMM", "en-US")),
          c = Table.FromColumns({ b, List.Repeat({a}, List.Count(b)) }, type table[Month=text, Amount=number])
        ][c], type table),
    FinalTable = Table.Combine(Ad_FinalTable[FinalTable])
in
    FinalTable

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.