Make a new column in power BI if [date] falls between [start of leave request] and [end…
- User
Make a new column in power BI if [date] falls between [start of leave request] and [end of leave request] put a 0, otherwise put a 1
- Assistant
To create a new column in Power BI that assigns a value of 0 if the date falls between the start and end of a leave request, and a value of 1 otherwise, you can follow these steps:
- Open your Power BI report and go to the "Fields" pane on the right side of the window.
- Right-click on the table or query where you want to add the new column and select "New Column" from the context menu.
- In the formula bar, enter the following DAX formula:
NewColumn = IF ( 'Table'[Date] >= 'Table'[Start of Leave Request] && 'Table'[Date] <= 'Table'[End of Leave Request], 0, 1 )Replace 'Table' with the actual name of your table or query, and [Date], [Start of Leave Request], and [End of Leave Request] with the respective column names that contain the date, start of leave request, and end of leave request values. 4. Press Enter to apply the formula.
Now, the new column (named "NewColumn" in this example) will be added to your table or query, and it will have a value of 0 if the date falls between the start and end of the leave request, and 1 otherwise.
- User
Explain how to do this if the date column is in a different table to the table with start and end dates
- Assistant
If the date column is located in a different table than the table containing the start and end dates, you can still create the new column in Power BI by following these steps:
- Open your Power BI report and go to the "Fields" pane on the right side of the window.
- Right-click on the table or query where you want to add the new column and select "New Column" from the context menu.
- In the formula bar, enter the following DAX formula:
NewColumn = IF ( 'Table1'[Date] >= RELATED('Table2'[Start of Leave Request]) && 'Table1'[Date] <= RELATED('Table2'[End of Leave Request]), 0, 1 )Replace 'Table1' with the actual name of the table or query that contains the date column and 'Table2' with the actual name of the table or query containing the start and end dates. Replace [Date], [Start of Leave Request], and [End of Leave Request] with the respective column names in their respective tables. 4. Press Enter to apply the formula.
Now, the new column (named "NewColumn" in this example) will be added to your table or query, and it will have a value of 0 if the date falls between the start and end of the leave request, and 1 otherwise. The RELATED function is used to fetch the related values from the other table based on the relationship established between the tables.
- User
Make an excel formula where if S1 is between I3 and J3, put a 1, otherwise put a zero
- Assistant
To create an Excel formula that returns 1 if S1 falls between I3 and J3, and 0 otherwise, you can use the following IF function:
=IF(AND(S1>=I3, S1<=J3), 1, 0)This formula uses the AND function to check if S1 is greater than or equal to I3 and less than or equal to J3. If both conditions are met, it returns 1, otherwise it returns 0. Replace S1, I3, and J3 with the actual cell references where the values are stored in your Excel sheet.