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.
Hello I hope you are well. I come to you for a little concern. I am looking for a Dax formula to handle the following case.
I have a STOP column that contains the week numbers of the aircraft shutdown dates and the second RESET column that contains the week numbers of the aircraft return to service. The goal is to have the number of devices stopped for each week but cumulatively by adding the devices still stopped from previous weeks.
For example the formula will consider all the week numbers present in the STOP column and for each week number check in the RESET column for each row the following conditions: take the week number 1 of the STOP column, if the RESET column is empty for some rows, these rows will be counted each time in the number of stops of the other weeks; if the number of the RESET column is equal to the week number of the STOP column, these lines are no longer considered when counting because these devices were put back into service the same day; if, for example, the RESET column contains week numbers that are higher than the week numbers in the STOP column,
these rows will be counted for all up to the week number of the corresponding RESET column ( Example Stop semine 1 and RESET week 4 line will be counted for week 1,2 and 3 only. Below is an example of data showing the 2 columns. The end result must be:
-week 1: 2 device shut down
-week 2: 2 devices + the 2 devices still shut down from week 1
-week 3: 2 devices shut down from week 2 + 1 device remaining from week 1.
From the conditions met by the RESET and STOP columns, the columns of the weeks are constructed and filled with 0 and 1
I had a solution of the problem on Excel and it is the reformulation in DAX I would like to have. In the attached screenshot, the columns containing the numbers represent the week numbers from 1 to the current week of the current year. Each row corresponds to an equipment and in each column if the equipment is immobilized during the week we put the number 0 and if it is put back into service we put the number 1. On the catch, for the first line the equipment is shut down during week 1 and returned to service in week 2, for the second line the equipment is immobilized in week 1 but was immediately returned to service in week 1 hence the number 1 in the column corresponding to week 1. For the third line, the equipment is immobilized from week 1 until week 14 when it was returned to service. The formula must be able to create the different columns of weeks and to have the number of equipment immobilized per week we will count the number of 0 for each column of week. Thanks in advance
User | Count |
---|---|
25 | |
12 | |
8 | |
8 | |
7 |
User | Count |
---|---|
27 | |
12 | |
12 | |
12 | |
6 |