Forum Discussion
Measure: LOOKUP Date
Hi all,
The measure 'Timesheet?' below returns a "Yes" in the date field if the Week Ending lies within the PlacementStartDate and PlacementEndDate for that placement (Export Placements table).
Instead of "Yes" is it possible to have "Approved" if the CandidateRef is present for that week in the 'Timesheets Export' table? And just "Yes" if the date lies within Placement Start Date - Placement End Date.
The measure for "Approved" will have to look up to the 'Timesheet Export'[Period Ending] date to see if a timesheet was approved in that week.
.pbix file:
https://www.dropbox.com/sh/q8czbh9haifer3a/AADaaXjf5VkrIztJuGAVfkFua?dl=0
Measure:
Hi HenryJS ,
Try the following measure:
Timesheet? = VAR temp_table = FILTER ( SUMMARIZE ( 'Timesheets export', 'Timesheets export'[Period Ending], 'Timesheets export'[Candidate Ref] ), 'Timesheets export'[Candidate Ref] = SELECTEDVALUE ( 'Export Placements'[CandidateRef] ) ) VAR Active = IF ( MAXX ( temp_table; 'Timesheets export'[Period Ending] ) <= MAX ( 'Calendar'[Date] ) && MAXX ( temp_table; 'Timesheets export'[Period Ending] ) >= MAX ( 'Calendar'[Date] ), "Active", "" ) VAR Yes_value = IF ( SELECTEDVALUE ( 'Export Placements'[PlacementStartDate] ) <= MAX ( 'Calendar'[Date] ) && SELECTEDVALUE ( 'Export Placements'[PlacementEndDate] ) >= MAX ( 'Calendar'[Date] ), "Yes", "" ) RETURN SWITCH ( TRUE (),Yes_value = "Yes" && Active = "Active", Active, Yes_value )Check PBIX file attach.
Hi HenryJS ,
Try the following:
Timesheet? = VAR temp_table = FILTER ( SUMMARIZE ( 'Timesheets export', 'Timesheets export'[Period Ending], 'Timesheets export'[Candidate Ref] ), 'Timesheets export'[Candidate Ref] = SELECTEDVALUE ( 'Export Placements'[CandidateRef] ) && 'Timesheets export'[Period Ending] = SELECTEDVALUE ( 'Calendar'[Week Ending] ) ) VAR Active = IF ( MAXX ( temp_table; 'Timesheets export'[Period Ending] ) <= MAX ( 'Calendar'[Date] ) && MAXX ( temp_table; 'Timesheets export'[Period Ending] ) >= MAX ( 'Calendar'[Date] ), "Active", "" ) VAR Yes_value = IF ( SELECTEDVALUE ( 'Export Placements'[PlacementStartDate] ) <= MAX ( 'Calendar'[Date] ) && SELECTEDVALUE ( 'Export Placements'[PlacementEndDate] ) >= MAX ( 'Calendar'[Date] ), "Yes", "" ) RETURN SWITCH ( TRUE (), Yes_value = "Yes" && Active = "Active", Active, Yes_value )These measure is based on the previous so if you may need to change the "" by blanks.
My bad,
Due to regional settings my DAX measure have a ; instead of a , and I replaced incorrectly on the measure I posted check measure below rectified:
Timesheet? = VAR temp_table = FILTER ( SUMMARIZE ( 'Timesheets export', 'Timesheets export'[Period Ending], 'Timesheets export'[Candidate Ref] ), 'Timesheets export'[Candidate Ref] = SELECTEDVALUE ( 'Export Placements'[CandidateRef] ) && 'Timesheets export'[Period Ending] = SELECTEDVALUE ( 'Calendar'[Week Ending] ) ) VAR Active = IF ( MAXX ( temp_table; 'Timesheets export'[Period Ending] ) <= MAX ( 'Calendar'[Date] ) && MAXX ( temp_table, 'Timesheets export'[Period Ending] ) >= MAX ( 'Calendar'[Date] ), "Active", "" ) VAR Yes_value = IF ( SELECTEDVALUE ( 'Export Placements'[PlacementStartDate] ) <= MAX ( 'Calendar'[Date] ) && SELECTEDVALUE ( 'Export Placements'[PlacementEndDate] ) >= MAX ( 'Calendar'[Date] ), "Yes", "" ) RETURN SWITCH ( TRUE (), Yes_value = "Yes" && Active = "Active", Active, Yes_value )If you see any othe ; on the measure replace by comma.
7 Replies
- MFelixSuper User
Hi HenryJS ,
Try the following measure:
Timesheet? = VAR temp_table = FILTER ( SUMMARIZE ( 'Timesheets export', 'Timesheets export'[Period Ending], 'Timesheets export'[Candidate Ref] ), 'Timesheets export'[Candidate Ref] = SELECTEDVALUE ( 'Export Placements'[CandidateRef] ) ) VAR Active = IF ( MAXX ( temp_table; 'Timesheets export'[Period Ending] ) <= MAX ( 'Calendar'[Date] ) && MAXX ( temp_table; 'Timesheets export'[Period Ending] ) >= MAX ( 'Calendar'[Date] ), "Active", "" ) VAR Yes_value = IF ( SELECTEDVALUE ( 'Export Placements'[PlacementStartDate] ) <= MAX ( 'Calendar'[Date] ) && SELECTEDVALUE ( 'Export Placements'[PlacementEndDate] ) >= MAX ( 'Calendar'[Date] ), "Yes", "" ) RETURN SWITCH ( TRUE (),Yes_value = "Yes" && Active = "Active", Active, Yes_value )Check PBIX file attach.