The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I currently have a column "DAYS VARIANCE" for the difference between two dates, calculated as "DATEDIFF(PUR_ONTIME[REQ DATE].[Date],PUR_ONTIME[REC DATE],DAY)". This calculation can return negative values (early deliveries) or positive values (late deliveries). I need this calculation to exclude weekends and holidays. I already have a column with a "1" for work days and a "0" for weekends/holidays. I can't simply add or subtract non-workdays since there could be positive or negative values. I suppose I could use a clunky "IF" function... but is there an easier way to do this?
I'm brand new to PBI.
Hi @Anonymous ,
I create a sample you can reference to modify your formulas.
Total Working Days = SUMX ( FILTER ( Table2, 'Table2'[Date] >= MIN(PUR_ONTIME[REQ DATE]) && 'Table2'[Date] <= MAX(PUR_ONTIME[REC DATE]) ), Table2[is work days] )
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-xuding-msft,
Thank you so much for your response! Unfortunately, your measure only returns a positive sum of working days for late deliveries where [REC DATE] >= [REQ DATE]. I need it to also return a negative sum of working days for early deliveries where [REC DATE] < [REQ DATE]. That is why I said "I can't simply add or subtract non-workdays since there could be positive or negative values," in other words, a simple sum function doesn't work. The measure should also return a '0' if [REC DATE] = [REQ DATE], regardless of whether or not it is a work day.
Alex
User | Count |
---|---|
78 | |
77 | |
36 | |
32 | |
29 |
User | Count |
---|---|
93 | |
79 | |
57 | |
48 | |
48 |