Forum Discussion
Calculate Overdues based off user entered interval
Creating a dynamic measure in Power BI that recalculates overdue items based on a user-selected interval can be achieved using a combination of a "What-If" parameter and DAX (Data Analysis Expressions). Here's a step-by-step guide to set this up:
1. Create the "What-If" Parameter
First, you need to create a "What-If" parameter that allows users to select the interval.
1. Go to the Modeling tab: In Power BI Desktop, click on the "Modeling" tab.
2. Select "New Parameter": From the "Modeling" tab, select "New Parameter".
3. Configure the Parameter: Set it up as follows:
- Name: Interval
- Data type: Whole Number
- Minimum value: 1 (or the minimum interval you want)
- Maximum value: 360 (or more if you want to allow larger intervals)
- Increment: Set this to the increment you want (e.g., 1, 5, 10).
- Default value: Set a default value (e.g., 30).
This will create a slicer in your report that lets users choose the interval.
2. Create a Dynamic Measure Using DAX
Next, you need to create a measure that dynamically calculates overdues based on the selected interval.
1. Create a New Measure: Right-click on your table in the Fields pane and choose "New measure".
2. Write the DAX Expression: Use a DAX formula to calculate overdues based on the chosen interval. Here's an example formula:
Dynamic Overdue =
VAR SelectedInterval = SELECTEDVALUE('Interval'[Interval], 30) // Default to 30 if nothing is selected
VAR MaxDate = TODAY()
VAR MinDate = MaxDate - SelectedInterval
RETURN
CALCULATE(
COUNTROWS('YourDataTable'),
'YourDataTable'[DueDate] > MinDate,
'YourDataTable'[DueDate] <= MaxDate
)
Replace `'YourDataTable'` and `[DueDate]` with your actual table name and column that contains the due dates.
3. Add the Measure to Your Report
Finally, add this measure to your report visuals. It will recalculate based on the interval selected in the "What-If" parameter slicer.
This approach will give you a flexible and user-interactive way of displaying overdues without creating individual measures for each interval.
If I answered your question, please mark this thread as accepted.
Follow me on LinkedIn:
https://www.linkedin.com/in/mustafa-ali-70133451/
amustafa I may have not explained it clearly,
this is what i am looking to achieve
every thing after "Date" is a measure
this is my: