Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
HenryJS
Post Prodigy
Post Prodigy

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:

 

Timesheet? = IF(SELECTEDVALUE('Export Placements'[PlacementStartDate])<= MAX('Calendar'[Date]) && SELECTEDVALUE('Export Placements'[PlacementEndDate]) >= MAX('Calendar'[Date]), "Yes", BLANK())
 
 
 
 
Capture111.JPG
 
 
 
3 ACCEPTED SOLUTIONS
MFelix
Super User
Super 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.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

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.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

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.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

7 REPLIES 7
MFelix
Super User
Super 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.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix Thanks so much for getting back to me. That looks like the resolution required.

 

Two things I was wondering if were possible:

  • Empty rows to be BLANK i.e. not visible if the row has no Yes or Active in
  • Totals (Counts) in the subheaders for each Week Ending

Hi @HenryJS ,

 

Just replace the "" by Blank on both formulas:

 

Try the following measure for the total sum make a:

SUMX(Calendar[Date]; [Timesheet?])

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix there's an issue with the measure you provided. If a candidate ref has more than one timesheet for different weeks in the 'Timesheets export' it will only pick up one from that table as 'Active'.

 

It needs to say Active for every week the candidate has a timesheet for.

 

An example is Anthony - 100252

 

He has a timesheet for WE 12/04 and 19/04

 

However table only says he has one for 19/04

 

Can you help?

 

Hope that makes sense

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.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix **bleep**! It says the syntax  for Timesheets export is incorrect?

 

Thanks for your help with this I really appreciate it.

 

Obrigado

 

Capture1.JPG

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.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.