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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Getting one column out of two date columns where the 1st one indicates the start and 2nd one end

Hi Dear Community experts,

 

I have the following issue of creating Power BI alternative of Excel function:

2 columns with start and end of campaigns are given and the budget of the campaign. Based on that information the daily spending is calculated.

The goal is to transform that 4 column table to a table with two columns: date column which will be conditionally linked to start and end of campaign (start date<= DATE <=end date) and respective total sum of all spendings od all campaigns for given day. 

Please check the attached screenshot which represents the issue. 

 

11

 

Will be very grateful for any advice/opinion you could share on this situation. 

 

Cheers, 

Saro

1 ACCEPTED SOLUTION

@Anonymous 

In Power BI, once you get the data from Excel into in Power query Window, Go to Advanced Editor and paste below code,. Make adjustments to the path of the file and table name. (my table is CostData in the example)

 

let
    Source = Excel.Workbook(File.Contents("C:\Users\Fowmy\Downloads\File0088.xlsx"), null, true),
    CostData_Table = Source{[Item="CostData",Kind="Table"]}[Data],
    #"Added Custom" = Table.AddColumn(CostData_Table, "Dates", each {Number.From([Start Date])..Number.From([End Date])}),
    #"Expanded Dates" = Table.ExpandListColumn(#"Added Custom", "Dates"),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded Dates",{{"Dates", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Dates"}, {{"Cost Per Day Amount", each List.Sum([Cost Per Day]), type number}})
in
    #"Grouped Rows"

 

https://1drv.ms/u/s!AmoScH5srsIYgYFf1P-rh0gnwwaW6A?e=U9Mwft

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

8 REPLIES 8
amitchandak
Super User
Super User

@Anonymous , refer if one the two can help

https://www.dropbox.com/s/yuv64v0cneseghx/value%20Split%20between%20months%20start%20end%20date.pbix?dl=0

https://www.dropbox.com/s/bqbei7b8qbq5xez/leavebetweendates.pbix?dl=0

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Fowmy
Super User
Super User

Hi@Anonymous 
Are you looking for a Power Query solution?

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Hi @Fowmy ,

 

thanks for reply. I need this in Power BI (NOT in Excel). So wherever that transformation can be done (at data tranasform stage or  as a measue) will be acceptable for me.  

@Anonymous 

Please use this power query solution. Assuming your data table name is CostData, you get the right output as desired.

let
    Source = Excel.CurrentWorkbook(){[Name="CostData"]}[Content],
    #"Added Custom" = Table.AddColumn(Source, "Dates", each {Number.From([Start Date])..Number.From([End Date])}),
    #"Expanded Dates" = Table.ExpandListColumn(#"Added Custom", "Dates"),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded Dates",{{"Dates", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Dates"}, {{"Cost Per Day Amount", each List.Sum([Cost Per Day]), type number}})
in
    #"Grouped Rows"


Annotation 2020-07-10 163840.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Dear @Fowmy

 

Thanks  so much for all efforts and sending this great solution. Do I understand correctly, this is a transformation, which is applied in Excel Power Query? 

 

If yes, that was not exactly what I was looking for. 

 

If it can be used in Power BI at which stage of data transformation and how I need to apply it, if my Excel file is already uploaded to Power BI desktop?

 

Many thanks again!

@Anonymous 

In Power BI, once you get the data from Excel into in Power query Window, Go to Advanced Editor and paste below code,. Make adjustments to the path of the file and table name. (my table is CostData in the example)

 

let
    Source = Excel.Workbook(File.Contents("C:\Users\Fowmy\Downloads\File0088.xlsx"), null, true),
    CostData_Table = Source{[Item="CostData",Kind="Table"]}[Data],
    #"Added Custom" = Table.AddColumn(CostData_Table, "Dates", each {Number.From([Start Date])..Number.From([End Date])}),
    #"Expanded Dates" = Table.ExpandListColumn(#"Added Custom", "Dates"),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded Dates",{{"Dates", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Dates"}, {{"Cost Per Day Amount", each List.Sum([Cost Per Day]), type number}})
in
    #"Grouped Rows"

 

https://1drv.ms/u/s!AmoScH5srsIYgYFf1P-rh0gnwwaW6A?e=U9Mwft

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

This is obviously almost a year since this post, but I have a question regarding your syntax. 
What is the benefit of using 

{Number.From([Start Date])..Number.From([End Date])}

rather than a List.DateTimes function? 

@lance_6 

 

I am creating a list of dates, when you create a list with { }, it needs numbers here so I convert the dates to number from Stsrt and End dates.

 

List.DateTime can also do the job but is lengthy.  

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors