I have a table with a cost column, a start date column and an end date column. I need to create either a measure or a calculated column that gives me the cost for every month/year between the start and end dates to relate with my calendar table and generate graphs with the sum for each month/year.
For example, I have this:
And I need it to be like this, taking the first cost as an example
Hi @aleaa
You can refer to the following example.
Create a new table first:
Table 2 = var a=CALENDAR(DATE(2020,1,1),date(2023,12,31))
return GENERATE(SUMMARIZE('Table',[Cost]),a)
Then create a column in new table:
Column = var _startdate=LOOKUPVALUE('Table'[Start Date],'Table'[Cost],'Table 2'[Cost])
var _enddate=LOOKUPVALUE('Table'[End Date],'Table'[Cost],'Table 2'[Cost])
return IF([Date]>=_startdate&&[Date]<=_enddate&&DAY([Date])=1,1,0)
Then filter the column:
Output:
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
When I created the column I got an error saying I inputed a table with many values and it was expected to be a single value.
Hi @aleaa
Can you provide the picture of error message, and do you create the table, then create the column?
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Find the message below (it's in Portuguese). And yes, first I created the table, then the column. I'm not sure why I got an error, but maybe it's because in my table (with the costs) I have similar costs for different periods of time. So I think it didn't find a single correspondent value and didn't know witch one to consider.
nothing, I need it to be just one day for each month/year that has a value
Yes, I need each line to be divided in multiple lines, one for each month with the separate costs. So for 01/09/2022 for example I'd have a line with 678, a line with 235.5, a line with 765.4, a line with 235.6 and a line with 6893
Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.
Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!
User | Count |
---|---|
106 | |
60 | |
45 | |
28 | |
24 |
User | Count |
---|---|
129 | |
94 | |
75 | |
43 | |
38 |