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!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hello PowerBI experienced/super users:
I'm very new with PowerBI and am trying to work on a DAX to give me a proper count of records if it falls within the set criteria.
Couple facts:
- I'm working on a dataset that is built by IT and calculated columns function is not available. Must use DAX to create measures only.
- All data I have is on same table
- Invoice due date & paid date is [Date] data type
Objective: calculate/count all the invoices that incompliance and out of compliance based on the set criterias below (based on the comparison between paid date vs. due date)
Table [Invoice] sample data: In this sample, I'd have a count of 2 in compliance and 2 out of compliance.
Invoice id | Invoice Number | Due Date | Paid Date | Compliance | ||
123 | A123 | 5/28/2022 | in compliance | In Compliance | count distinct invoice id if paid date < due date or (due date > today() and paid date = null) | |
15648 | INV-563 | 3/28/2022 | 3/27/2022 | in compliance | Out of compliance | count distinct invoice id if paid date > due date or (due date < today () and paid date = null) |
78A656 | 7589-IN | 2/22/2022 | 2/15/2022 | in compliance | ||
15647 | INV-111 | 3/28/2022 | 4/1/2022 | out of compliance | ||
89 | B899123 | 4/27/2022 | out of compliance |
|
Thank you very much for your time!! Any help is greatly appreciated.
P.Ha
Solved! Go to Solution.
@p-ha . Try measures
Calculate(DistinctCOUNT(Table[invoice id]), filter(Table,[paid date] < [due date] || ([due date] > today() && isblank([paid date]))))
2.
Calculate(DistinctCOUNT(Table[invoice id]), filter(Table,[paid date] > [due date] || ([due date] < today() && isblank([paid date]))))
Hi,
Please try this
@amitchandak thank you so much! the guided DAX worked!!
1 additional question please if you don't mind, what if my due date falls on the weekend? Is there anything we can add to the current DAX to caviat that if due date falls into weekend, the next earliest paid date is still consider on time? (e.g. due 4/30/2022 [Saturday], paid 5/2/2022 [earliest next Monday] --> on time payment, rather than the dax to compare just thes sequel of the date itself)
OR -
if we can incorporate into the measure to push the due date to the next business day if it falls in the weekend (since all the Paid date will defaulted to the business days only)
Thank you again!
P.Ha
Hi,
Step 1 : First you should create weekday column from due date column:
@p-ha . Try measures
Calculate(DistinctCOUNT(Table[invoice id]), filter(Table,[paid date] < [due date] || ([due date] > today() && isblank([paid date]))))
2.
Calculate(DistinctCOUNT(Table[invoice id]), filter(Table,[paid date] > [due date] || ([due date] < today() && isblank([paid date]))))
User | Count |
---|---|
15 | |
11 | |
6 | |
6 | |
5 |
User | Count |
---|---|
29 | |
17 | |
11 | |
7 | |
5 |