The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Data Table
SiteMeterIdentifier | Account Number | Invoice Start Date | Invoice End Date |
1 | 2 | 01/11/2023 | 30/11/2023 |
1 | 2 | 01/01/2024 | 31/01/2024 |
1 | 2 | 01/03/2024 | 31/03/2024 |
1 | 2 | 01/04/2024 | 30/04/2024 |
Expected Output
SiteMeterIdentifier | Account Number | Invoice Start Date | Invoice End Date |
1 | 2 | 01/04/2024 | 30/04/2024 |
1 | 2 | 01/02/2024 | 29/02/2024 |
Can this be managed through a DAX Measure?
Solved! Go to Solution.
Create the following calculated columns
Next Invoice Start Date =
CALCULATE(
MIN(Invoice[Invoice Start Date]),
FILTER(
Invoice,
Invoice[Account Number] = EARLIER(Invoice[Account Number]) &&
Invoice[SiteMeterIdentifier] = EARLIER(Invoice[SiteMeterIdentifier]) &&
Invoice[Invoice Start Date] > EARLIER(Invoice[Invoice Start Date])
)
)
Gap Start Date =
IF(
ISBLANK(Invoice[Next Invoice Start Date]),
BLANK(),
IF(
DATEDIFF(Invoice[Invoice End Date], Invoice[Next Invoice Start Date], DAY) > 1,
Invoice[Invoice End Date] + 1,
BLANK()
)
)
Gap End Date =
IF(
ISBLANK(Invoice[Next Invoice Start Date]),
BLANK(),
IF(
DATEDIFF(Invoice[Invoice End Date], Invoice[Next Invoice Start Date], DAY) > 1,
Invoice[Next Invoice Start Date] - 1,
BLANK()
)
)
Create the following calculated columns
Next Invoice Start Date =
CALCULATE(
MIN(Invoice[Invoice Start Date]),
FILTER(
Invoice,
Invoice[Account Number] = EARLIER(Invoice[Account Number]) &&
Invoice[SiteMeterIdentifier] = EARLIER(Invoice[SiteMeterIdentifier]) &&
Invoice[Invoice Start Date] > EARLIER(Invoice[Invoice Start Date])
)
)
Gap Start Date =
IF(
ISBLANK(Invoice[Next Invoice Start Date]),
BLANK(),
IF(
DATEDIFF(Invoice[Invoice End Date], Invoice[Next Invoice Start Date], DAY) > 1,
Invoice[Invoice End Date] + 1,
BLANK()
)
)
Gap End Date =
IF(
ISBLANK(Invoice[Next Invoice Start Date]),
BLANK(),
IF(
DATEDIFF(Invoice[Invoice End Date], Invoice[Next Invoice Start Date], DAY) > 1,
Invoice[Next Invoice Start Date] - 1,
BLANK()
)
)
Expected Output
Expected Output
SiteMeterIdentifier | Account Number | Invoice Start Date | Invoice End Date |
1 | 2 | 01/12/2023 | 31/12/2023 |
1 | 2 | 01/02/2024 | 29/02/2024 |
User | Count |
---|---|
15 | |
8 | |
6 | |
6 | |
5 |
User | Count |
---|---|
25 | |
13 | |
13 | |
8 | |
8 |