Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hi!
I have two tables that follow this structure:
Calendar
| Year-Quarter | Year |
| 2024 Q1 | 2024 |
| 2024 Q2 | 2024 |
| 2024 Q3 | 2024 |
| 2024 Q4 | 2024 |
| 2025 Q1 | 2025 |
| 2025 Q2 | 2025 |
| 2025 Q3 | 2025 |
| 2025 Q4 | 2025 |
Sales
| Year-Quarter | FileDate | PlannedCompletionDate | Status |
| 2024 Q1 | 23/03/2024 | 01/02/2023 | X |
| 2024 Q2 | 19/06/2024 | 19/04/2024 | ScheduledForCompletion |
| 2024 Q3 | 30/09/2024 | 13/07/2024 | X |
| 2024 Q4 | 13/12/2024 | 22/12/2024 | ScheduledForCompletion |
| 2025 Q1 | 30/03/2025 | 04/02/2025 | ScheduledForCompletion |
| 2025 Q2 | 30/06/2025 | 30/11/2025 | X |
| 2025 Q3 | 30/09/2025 | 19/09/2025 | X |
| 2025 Q3 | 30/09/2025 | 27/09/2025 | ScheduledForCompletion |
| 2025 Q4 | 26/12/2025 | 23/11/2025 | ScheduledForCompletion |
In my dashboard, I have a "Year-Quarter" filter coming from the Calendar table. My two tables are related by the Year-Quarter column. I want to create a measure that counts rows in my Sales table where it checks, in the FileDate column, which date refers to the Year-Quarter filtered by the user and then counts the number of rows where the Status column = "ScheduledForCompletion" and the PlannedCompletionDate column is in the next 6 months from the specified FileDate.
Example 1: If the user filters 2025 Q2, the measure should show the value 3 because based on the FileDate for 2025 Q2 (30/06/2025), there are three rows with "ScheduledForCompletion" status in the next six months:
| 2025 Q3 | 30/09/2025 | 27/09/2025 | ScheduledForCompletion |
| 2025 Q4 | 26/12/2025 | 23/11/2025 | ScheduledForCompletion |
| 2024 Q4 | 13/12/2024 | 22/12/2025 | ScheduledForCompletion |
Example 2: If the user filters 2024 Q4, the measure should show the value 2 because based on the FileDate for 2024 Q4 (13/12/2024), there are two rows with "ScheduledForCompletion" status in the next six months:
| 2024 Q4 | 13/12/2024 | 22/12/2024 | ScheduledForCompletion |
| 2025 Q1 | 30/03/2025 | 04/02/2025 | ScheduledForCompletion |
How can I do that measure?
Solved! Go to Solution.
@nok Hello again 😅
Did you mean something like this:
Count Scheduled Next 6M =
VAR SelQ =
SELECTEDVALUE ( 'Calender'[Year-Quarter] )
VAR RefDate =
CALCULATE (
MAX ( FactSales[FileDate] ),
FILTER (
ALL ( FactSales[Year-Quarter], FactSales[FileDate] ),
FactSales[Year-Quarter] = SelQ
)
)
VAR EndDate = EDATE ( RefDate, 6 )
RETURN
IF (
ISBLANK ( RefDate ),
BLANK (),
CALCULATE (
COUNTROWS ( FactSales ),
KEEPFILTERS ( FactSales[Status] = "ScheduledForCompletion" ),
KEEPFILTERS ( FactSales[PlannedCompletionDate] >= RefDate ),
KEEPFILTERS ( FactSales[PlannedCompletionDate] <= EndDate ),
ALL ( 'Calender' ),
ALL ( FactSales[Year-Quarter] )
)
)
@nok Hello again 😅
Did you mean something like this:
Count Scheduled Next 6M =
VAR SelQ =
SELECTEDVALUE ( 'Calender'[Year-Quarter] )
VAR RefDate =
CALCULATE (
MAX ( FactSales[FileDate] ),
FILTER (
ALL ( FactSales[Year-Quarter], FactSales[FileDate] ),
FactSales[Year-Quarter] = SelQ
)
)
VAR EndDate = EDATE ( RefDate, 6 )
RETURN
IF (
ISBLANK ( RefDate ),
BLANK (),
CALCULATE (
COUNTROWS ( FactSales ),
KEEPFILTERS ( FactSales[Status] = "ScheduledForCompletion" ),
KEEPFILTERS ( FactSales[PlannedCompletionDate] >= RefDate ),
KEEPFILTERS ( FactSales[PlannedCompletionDate] <= EndDate ),
ALL ( 'Calender' ),
ALL ( FactSales[Year-Quarter] )
)
)
I would start with something like this below. Also Maybe consider adding a date column to the calendar table and join the calendar table to the filedate column (if possible):
VAR _sixMonths = DateAdd(Sales[FileDate], 6, Month)
VAR _FileDate = SELECTEDVALUE(Sales[Filedate))
VAR Result =
CALCULATE(COUNTROWS(Sales), Sales[ScheduledForCompletion] = "ScheduledForCompletion", DatesBetween(Sales[PlannedCompletionDate], _FileDate, _sixMonths))
RETURN Result
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 51 | |
| 37 | |
| 35 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 70 | |
| 65 | |
| 39 | |
| 33 | |
| 23 |