Forum Discussion
Read slicer values, retrieve corresponding table column values and use them to check existence
- 1 year ago
Hi kevinfernandez ,
You can achieve this in Power BI using a DAX measure that dynamically filters the Calendar table based on the selected fiscal period(s) in the slicer, retrieves the corresponding dates, and checks for any matches with the Joined date column in the Employee table. The idea is to create a measure that reads the selected values in the slicer, pulls the relevant dates from the calendar, and counts how many of those dates exist in the employee data.
Here is the DAX measure that returns the count of employees who joined during the selected fiscal period(s):
JoinedInSelectedPeriod = VAR SelectedDates = CALCULATETABLE( VALUES('Calendar'[Date]), 'Calendar' ) RETURN COUNTROWS( FILTER( 'Employee', 'Employee'[Joined date] IN SelectedDates ) )This measure calculates the list of dates from the Calendar table based on the slicer selection and checks if those dates are found in the Joined date column of the Employee table. If you prefer to return a simple TRUE/FALSE flag indicating whether at least one employee joined during the selected period, you can use the following version:
AnyJoinInSelectedPeriod = VAR SelectedDates = CALCULATETABLE( VALUES('Calendar'[Date]), 'Calendar' ) RETURN IF( COUNTROWS( FILTER( 'Employee', 'Employee'[Joined date] IN SelectedDates ) ) > 0, TRUE, FALSE )These measures work as long as the slicer is based on 'Calendar'[Fiscal Year Period] and both date columns are of the same data type. Let me know if you'd like to display the list of employee names instead.
Best regards,
Create a data model. Join the calendar date to the "joined" date. Then add your output columns to a table or orther visual. No code required.
- RonanCampbell1 year agoFrequent Visitor
I'd come at it in the same way as lbendlin on the model side. Would also put a date table inbetween your two tables above
- kevinfernandez1 year agoFrequent Visitor
Could you please help me understand how that helps? It would really help me to keep your suggestion as a backup in future. Thanks!
- kevinfernandez1 year agoFrequent Visitor
Thanks lbendlin but I was looking for the exact dax formulas so that I can get those selected dates and further use them for my calculation.