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.
Hello everyone. I ask you for help with this problem that I have. I have reviewed many post but I do not give with the solution. I have been able to do it in Excel but not in Power BI.
RESTAR 2 DATES WITHOUT WEEKENDS:
I need to subtract 2 dates that are in the same table. But the result should be without the weekends.
For example: Creation Date is 08/16/2017 and the end date is 08/22/2017. The result of a simple subtraction would be 6; But what I need is that I do not take the weekends. The result should be 4.
HOLIDAYS:
Perhaps in another column or in the same one of the case of paragraph above, if in that period of the 2 dates exists a holiday also must subtract it.
Example: Between 04/07/2017 and 07/07/2017 we have 05/07/2017 which is Holiday. The result should be: 2 (3 days minus 1 holiday = 2).
The ideas that come to mind are:
1.- The total result is in a column or
2.- A column with the number of holidays between those dates, another column with the number of Weekends between those dates and then the final column of results
The image below is an example of the expected results
Thank you!
Hi,
Please check the below picture and the attached pbix file.
It is for creating a measure.
expected result measure: =
VAR _list =
CALENDAR ( MIN ( data[date_start] ), MAX ( data[date_end] ) )
VAR _holidaylist =
{ DATE ( 2017, 7, 5 ) }
VAR _weekendlist =
SUMMARIZE (
FILTER (
ADDCOLUMNS ( _list, "dayname", FORMAT ( [Date], "dddd" ) ),
[dayname] IN { "Saturday", "Sunday" }
),
[Date]
)
RETURN
IF (
HASONEVALUE ( data[customer_id] ),
COUNTROWS (
FILTER ( _list, NOT ( [Date] IN _holidaylist && [Date] IN _weekendlist ) )
) - 1
)