Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi Power BI community, i am encountering an issue with a line graph visualization in Power BI and need some guidance. My objective is to display data in the line graph only if the user's date range selection via a date slicer does not exceed 14 days. For selections over 14 days, the graph should not display any data.
Here are the steps and DAX measures i implemented:
1. Calculate Minimum and Maximum Dates selected by User:
MinDateSelected = MIN(Data[Date])
MaxDateSelected = MAX(Data[Date])
2. Determine the daterange:
Using these measures, i calculated the date range selected:
DateRange = DATEDIFF([MinDateSelected],[MaxDateSelected],DAY) + 1
3. Conditional measure for displaying the data:
Next, i created a measure intended to conditionally display data based on the date range:
DisplayData = IF([DateRange] <=14,1,BLANK())
The DisplayData measure performs as expected within a card visual, showing 1 when the selection is within 14 days, and displaying blank for selections that exceed 14 days.
However, when applying this measure as a visual-level filter on the line graph (set to show items when the value is 1), the graph continue to display all data points, regardless of the selected date range.
On Y axis, the field of Start Time refers to DateTime format (e.g. 2/6/2024 11:05:08).
Has anyone faced a similar challenge or can offer adviceon how to ensure the line graph adheres to this conditional display based on the date range selected?
Thank you!
Solved! Go to Solution.
Try using ALLSELECTED to get the slicer dates.
MinDateSelected = MINX ( ALLSELECTED ( Data ), Data[Date] )
MaxDateSelected = MAXX ( ALLSELECTED ( Data ), Data[Date] )
Proud to be a Super User!
Try using ALLSELECTED to get the slicer dates.
MinDateSelected = MINX ( ALLSELECTED ( Data ), Data[Date] )
MaxDateSelected = MAXX ( ALLSELECTED ( Data ), Data[Date] )
Proud to be a Super User!
User | Count |
---|---|
99 | |
86 | |
78 | |
75 | |
71 |
User | Count |
---|---|
112 | |
105 | |
96 | |
74 | |
66 |