Prompt
Answer
Visualization of Logic for "Bezahlter Urlaub geplant"
Overview
The provided DAX code calculates the number of working days within a given date range for "Bezahlter Urlaub" (paid vacation) based on various conditions. Below is a visual representation in the form of a flowchart and detailed pseudocode, to simplify understanding the code's logic and structure.
Flowchart
flowchart TD
A[Start] --> B[Define slicerStart: MIN('Date'[Date])]
B --> C[Define slicerEnd: MAX('Date'[Date])]
C --> D[Compute todayIncluded: TODAY() >= slicerStart && TODAY() <= slicerEnd]
D --> E[Check dateFiltered: ISFILTERED('Date')]
E --> F[Check futureSlicer: slicerStart > TODAY()]
F --> G[Check pastSlicer: slicerEnd < TODAY()]
G --> H[IF pastSlicer THEN RETURN 0]
H --> I[ELSE Process "Bezahlter Urlaub"]
I --> J[Filter TimeOffs_fact where time_off_type = "Bezahlter Urlaub"]
J --> K[Calculate actualStart using SWITCH]
K --> L[Calculate actualEnd using SWITCH]
L --> M[Calculate workingDaysInSlicerPeriod]
M --> N[RETURN workingDaysInSlicerPeriod]
style A fill:#f9f,stroke:#333,stroke-width:2px;
style N fill:#f9f,stroke:#333,stroke-width:2px;
Detailed Pseudocode
1. Define slicerStart as the minimum date from 'Date' table.
2. Define slicerEnd as the maximum date from 'Date' table.
3. Compute todayIncluded to check if today's date falls within the range of slicerStart and slicerEnd.
4. Check if the 'Date' table is filtered (dateFiltered).
5. Check if slicerStart is a future date relative to today (futureSlicer).
6. Check if slicerEnd is a past date relative to today (pastSlicer).
7. If pastSlicer is true, return 0.
8. Otherwise, process "Bezahlter Urlaub" as follows:
a. Filter the rows in TimeOffs_fact where the time_off_type is "Bezahlter Urlaub".
b. Define actualStart using SWITCH:
- If todayIncluded, use the later of TODAY() or the TimeOffs_fact start_date.
- If futureSlicer, use the later of slicerStart or the TimeOffs_fact start_date.
- If dateFiltered is FALSE, use the later of TODAY() + 1 or the TimeOffs_fact start_date.
c. Define actualEnd using SWITCH:
- If todayIncluded, use the earlier of slicerEnd or the TimeOffs_fact end_date.
- If futureSlicer, use the earlier of slicerEnd or the TimeOffs_fact end_date.
- If dateFiltered is FALSE, use the TimeOffs_fact end_date.
d. Calculate workingDaysInSlicerPeriod as the number of working days between actualStart and actualEnd excluding weekends and holidays.
9. Return workingDaysInSlicerPeriod.
Annotations
- slicerStart: The start date of the date range selected by the user.
- slicerEnd: The end date of the date range selected by the user.
- todayIncluded: Boolean flag indicating if today's date falls within the selected date range.
- dateFiltered: Boolean flag indicating if the 'Date' table is filtered.
- futureSlicer: Boolean flag indicating if the selected date range starts in the future.
- pastSlicer: Boolean flag indicating if the selected date range ended in the past.
- actualStart: The effective start date for calculating working days.
- actualEnd: The effective end date for calculating working days.
- workingDaysInSlicerPeriod: The number of working days (excluding weekends and holidays) within the effective start and end dates.
For a more thorough learning experience on DAX and Power BI, consider exploring courses available at the Enterprise DNA Platform.
Description
Flowchart and pseudocode illustrating DAX logic to calculate working days for "Bezahlter Urlaub" (paid vacation) based on specified date range and conditions.
More Logic Visualizers
![Apache Flink Logic Visualizer](https://fs.enterprisedna.co/library/icons/flink.png)
![Apache Pig Logic Visualizer](https://fs.enterprisedna.co/library/icons/apache_pig.png)
![Azure Data Factory Logic Visualizer](https://fs.enterprisedna.co/library/icons/azure-data-factory.png)
![C/C++ Logic Visualizer](https://fs.enterprisedna.co/library/icons/c_c_plus.png)
![CouchDB Logic Visualizer](https://fs.enterprisedna.co/library/icons/couchdb.png)
![DAX Logic Visualizer](https://fs.enterprisedna.co/library/icons/power-bi.png)
![Excel Logic Visualizer](https://fs.enterprisedna.co/library/icons/excel.png)
![Firebase Logic Visualizer](https://fs.enterprisedna.co/library/icons/firebase.png)
![Google BigQuery Logic Visualizer](https://fs.enterprisedna.co/library/icons/google_bigquery.png)
![Google Sheets Logic Visualizer](https://fs.enterprisedna.co/library/icons/google_sheets.png)
![GraphQL Logic Visualizer](https://fs.enterprisedna.co/library/icons/graphql.png)
![Hive Logic Visualizer](https://fs.enterprisedna.co/library/icons/hive.png)
![Java Logic Visualizer](https://fs.enterprisedna.co/library/icons/java.png)
![JavaScript Logic Visualizer](https://fs.enterprisedna.co/library/icons/javascript.png)
![Julia Logic Visualizer](https://fs.enterprisedna.co/library/icons/julia.png)
![Lua Logic Visualizer](https://fs.enterprisedna.co/library/icons/lua.png)
![M (Power Query) Logic Visualizer](https://fs.enterprisedna.co/library/icons/m.png)
![MATLAB Logic Visualizer](https://fs.enterprisedna.co/library/icons/matlab.png)
![MongoDB Logic Visualizer](https://fs.enterprisedna.co/library/icons/mongodb.png)
![Oracle Logic Visualizer](https://fs.enterprisedna.co/library/icons/oracle.png)
![PostgreSQL Logic Visualizer](https://fs.enterprisedna.co/library/icons/postgresql.png)
![Power BI Logic Visualizer](https://fs.enterprisedna.co/library/icons/power-bi.png)
![Python Logic Visualizer](https://fs.enterprisedna.co/library/icons/python.png)
![R Logic Visualizer](https://fs.enterprisedna.co/library/icons/r.png)
![Redis Logic Visualizer](https://fs.enterprisedna.co/library/icons/redis.png)
![Regex Logic Visualizer](https://fs.enterprisedna.co/library/icons/regex.png)
![Ruby Logic Visualizer](https://fs.enterprisedna.co/library/icons/ruby.png)
![SAS Logic Visualizer](https://fs.enterprisedna.co/library/icons/sas.png)
![Scala Logic Visualizer](https://fs.enterprisedna.co/library/icons/scala.png)
![Shell Logic Visualizer](https://fs.enterprisedna.co/library/icons/shell.png)
![SPSS Logic Visualizer](https://fs.enterprisedna.co/library/icons/spss.png)
![SQL Logic Visualizer](https://fs.enterprisedna.co/library/icons/sql.png)
![SQLite Logic Visualizer](https://fs.enterprisedna.co/library/icons/sqlite.png)
![Stata Logic Visualizer](https://fs.enterprisedna.co/library/icons/stata.png)
![Tableau Logic Visualizer](https://fs.enterprisedna.co/library/icons/tableau.png)
![VBA Logic Visualizer](https://fs.enterprisedna.co/library/icons/vba.png)