Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I've a data base, for Invoices paid on the last few months. I've Invoice Date, Invoice Creation Date, Invoice Due Date and Invoice Payment Date. In other table I've a calendar with Dates based on a cycle(Image below)
My use case is:
| Invoice Number | Due Date | Payment Date | Invoice Date | Invoice Creation Date | Cycle Date |
| 039 | 2/28/2022 | 2/28/2022 | 2/18/2022 | 2/28/2022 | ? |
In summary I need to find the closest date related to my "Due Date". In that example I'll use Cycle 9, Cycle date 2/28/2022.
Solved! Go to Solution.
Hi @yagoframos
Please find attached sample file containing both options.
Cycle Date 2 =
MAXX (
TOPN (
1,
FILTER (
'Calendar',
'Calendar'[Month Number] = MONTH ( PaidInvoices[Due Date] )
&& PaidInvoices[Due Date] - 'Calendar'[Date] >= 0
),
PaidInvoices[Due Date] - 'Calendar'[Date],
ASC
),
'Calendar'[Date]
)
Hi @yagoframos
Assuming that you are creating a calculated column and that the Calendar table is unpivotted as suggested by @FreemanZ then you may try the following
Cycle Date =
MAXX (
TOPN (
1,
FILTER (
'Calendar',
'Calendar'[Month Number] = MONTH ( PaidInvoices[Due Date] )
),
ABS ( PaidInvoices[Due Date] - 'Calendar'[Date] ), ASC
),
'Calendar'[Date]
)
Awesome!!! That works for the next Cycle, and if I want to see the first one before the due date?
Hi @yagoframos
Please find attached sample file containing both options.
Cycle Date 2 =
MAXX (
TOPN (
1,
FILTER (
'Calendar',
'Calendar'[Month Number] = MONTH ( PaidInvoices[Due Date] )
&& PaidInvoices[Due Date] - 'Calendar'[Date] >= 0
),
PaidInvoices[Due Date] - 'Calendar'[Date],
ASC
),
'Calendar'[Date]
)
Thank you!!!
hi @yagoframos
the point might be to unpivot your table first to like:
| Month | MonthNo | Cycle | Date |
| Jan | 1 | Cycle1 | 1/4/2022 |
| … |
then everything become easier.
That should't be a problem, my only concern is the best way to use the LOOKUP to find the right date.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 9 | |
| 9 | |
| 8 | |
| 6 | |
| 6 |
| User | Count |
|---|---|
| 21 | |
| 20 | |
| 20 | |
| 14 | |
| 14 |