Quantcast
Channel: Power Query topics
Viewing all articles
Browse latest Browse all 31342

Create revenue records from salesorder

$
0
0

I have a salesorder table with StartDate, EndDate and Interval in Power BI and I would like to create revenue records by PowerQuery. Revenue records should be created per salesorder, from the StartDate to the EndDate with an Interval of 1, 3 or 12 months. These records should have a RevenueDate and salesorderid (=GUID). The following Power Query M formula gives Expression.Error: We cannot apply field access to the type Date.
Details:
Value=01/12/2024
Key=EndDate

 

The first record of salesorder has 01/12/2024 as StartDate. Both StartDate and EndDate have the Date Type and I filtered out the salesorder records that have a blank StartDate or EndDate just te be sure. I think maybe it has something to do with trying to get the salesorder column values from the list correctly. But I can't figure out how to make it right.

 

How can I solve this?

 

let Source = salesorder, AddRevenueDates = Table.AddColumn(Source, "RevenueDates", each List.Generate( () => [StartDate], // Starting value each _ <= [EndDate], // Create only when <= EndDate each Date.AddMonths( _, [Interval] ) // Take steps of x months ) ), ExpandRevenueDates = Table.ExpandListColumn(AddRevenueDates, "RevenueDates"), RenameColumns = Table.RenameColumns(ExpandRevenueDates, {{"RevenueDates", "RevenueDate"}}), SelectColumns = Table.SelectColumns(RenameColumns, {"RevenueDate", "salesorderid"}) in SelectColumns

 


Viewing all articles
Browse latest Browse all 31342

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>