Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi there.
I have a table of data I am pulling into PBI desktop that looks similar to the below:
placement id | start date | end date |
1 | 01/01/2024 | 01/05/2024 |
2 | 01/01/2024 | 01/02/2024 |
3 | 01/02/2024 | 01/03/2024 |
4 | 01/02/2024 | 01/06/2024 |
5 | 01/02/2024 | 31/02/2024 |
6 | 01/01/2024 | 31/01/2024 |
7 | 01/03/2024 | 01/04/2024 |
8 | 01/03/2024 | 01/04/2024 |
9 | 01/03/2024 | 01/05/2024 |
10 | 01/04/2002 | 01/07/2024 |
My aim is to create a bar chart that shows when Active Placements against the last 3 months (i.e. A placement is active in that month if the start date is before the last day, and the end date is after the first day).
The issue is that placements will be active over multiple months so I want placements to be counted multiple times.
So far I have only been able to achieve this by adding 3 flag columns onto the table - marking as active or not active in month1, month2, month3 - and then creating a measure to calculate the total count.
placement id | start date | end date | month1 | month2 | month3 |
1 | 01/01/2024 | 01/05/2024 | 1 | 1 | 1 |
2 | 01/01/2024 | 01/02/2024 | 1 | 1 | |
3 | 01/02/2024 | 01/03/2024 | 1 | 1 | |
4 | 01/02/2024 | 01/06/2024 | 1 | 1 | |
5 | 01/02/2024 | 31/02/2024 | 1 | ||
6 | 01/01/2024 | 31/01/2024 | 1 | ||
7 | 01/03/2024 | 01/04/2024 | 1 | ||
8 | 01/03/2024 | 01/04/2024 | 1 | ||
9 | 01/03/2024 | 01/05/2024 | 1 | ||
10 | 01/04/2002 | 01/07/2024 |
However, with the amount of other flags I need to consider, this will eventually require the addition of ~50 more columns. Which isn't neat or a great for processing time.
Is there a better way to do this? i.e. Can I split my data into a more refined model?
Thanks
Solved! Go to Solution.
Hi @Beth_H
You can use the linked pattern, it is very simple to use.
Note that the calendar has to be without a relationship with your fact table.
https://blog.finance-bi.com/power-bi-employee-count-by-month/
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
Hello @Beth_H,
Can you please try this approach:
1. Create a date table that covers the range of your data
let
StartDate = #date(2024, 1, 1),
EndDate = #date(2024, 12, 31),
DateList = List.Dates(StartDate, Duration.Days(EndDate - StartDate) + 1, #duration(1, 0, 0, 0)),
DateTable = Table.FromList(DateList, Splitter.SplitByNothing(), {"Date"}),
TypeChanged = Table.TransformColumnTypes(DateTable,{{"Date", type date}})
in
TypeChanged
2. Then, expand each placement record into individual months during which the placement is active. (Ensure the relationship between your date table and your transformed placements table exists)
let
Source = YourPlacementTable,
AddMonths = Table.AddColumn(Source, "Months", each {Number.From([start date])..Number.From([end date])}),
ExpandMonths = Table.ExpandListColumn(AddMonths, "Months"),
AddYearMonth = Table.AddColumn(ExpandMonths, "YearMonth", each Date.ToText(Date.From([Months]), "yyyy-MM")),
RemoveUnnecessaryColumns = Table.RemoveColumns(AddYearMonth,{"Months", "start date", "end date"})
in
RemoveUnnecessaryColumns
3. Finally, create a measure to count the active placements for each month.
Active Placements =
CALCULATE(
COUNTROWS(YourTransformedPlacementTable),
FILTER(
YourTransformedPlacementTable,
YourTransformedPlacementTable[YearMonth] = FORMAT(MAX('DateTable'[Date]), "yyyy-MM")
)
)
Hope this helps!
Hi @Beth_H
You can use the linked pattern, it is very simple to use.
Note that the calendar has to be without a relationship with your fact table.
https://blog.finance-bi.com/power-bi-employee-count-by-month/
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
This works perfectly! Thank you.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
57 | |
55 | |
55 | |
37 | |
30 |
User | Count |
---|---|
78 | |
66 | |
45 | |
44 | |
40 |