Forum Discussion

HenryJS's avatar
HenryJS
Icon for Post Prodigy rankPost Prodigy
6 years ago
Solved

Measure: Text & Date

Hi all,

 

I have two tables:

  • 'Merge1'
  • 'Export Actions'

 

I need a measure which:

  • If CandidateRef in Merge1 has a Export Actions[ActionName] = "Call - Update"
  • & 'Export Actions'[ActionDate] >= Latest Monday
  • THEN Yes

 

Latest Monday returning only actions from the most recent monday onwards

 

Hope that's clear and thanks again!

 

Merge 1 table

 

 

 

Export Actions

 

  • Hi HenryJS 

    Check if this result is ok.

    To get this, I create a date table

    date table =
    ADDCOLUMNS (
        CALENDARAUTO (),
        "year", YEAR ( [Date] ),
        "month", MONTH ( [Date] ),
        "week", WEEKNUM (
            [Date],
            2
        ),
        "weekday", WEEKDAY (
            [Date],
            2
        )
    )
    

    Then Create measures

    name =
    LOOKUPVALUE (
        'Export Candidates'[Candidate Name],
        'Export Candidates'[CandidateRef], MAX ( 'Export Actions'[CandidateRef] )
    )
    
    lastMonday =
    CALCULATE (
        MAX ( 'date table'[Date] ),
        FILTER (
            ALL ( 'date table' ),
            'date table'[weekday] = 1
                && 'date table'[Date]
                    <= TODAY ()
        )
    )
    
    
    Contacted Since Monday =
    IF (
        [name]
            <> BLANK ()
            && MAX ( [action.date] ) <= [lastMonday]
            && MAX ( [ActionName] ) = "Call - Update",
        "Yes",
        "No"
    )
    
    Contact By = IF([Contacted Since Monday]="Yes",MAX([UserName]))
    
    Contacted on = IF([Contacted Since Monday]="Yes",MAX([ActionDate]))
    

    [action.date] is a calculated column

    action.date = [ActionDate].[Date]

     

    Best Regards
    Maggie
    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

    • HenryJS's avatar
      HenryJS
      Icon for Post Prodigy rankPost Prodigy

      Hi Greg_Deckler 

       

      I need three columns/measures (not sure which ones more applicable)

       

      Contacted Since Monday

      • If 'Export Candidates'[CandidateRef] = 'Export Actions'[CandidateRef]
      • & 'Export Actions'[ActionDate] >= Latest Monday onwards
      • & 'Export Actions'[ActionName] = "Call - Update"
      • THEN "Yes"

       

      Contact By

      • If 'Contacted Since Monday' = "Yes"
      • RETURN 'Export Actions'[Username] for latest Action

       

      Contacted on

      • If 'Contacted Since Monday' = "Yes"
      • RETURN 'Export Actions'[ActionDate] for latest Action

       

       

       

      'Export Actions'

       

      CandidateRefCandidateUserNameActionNameActionDate
      38731Jason RepetiPenelope WareCall - Update06/04/2020 18:26
      90770Victor KingsleyPenelope WareCall - Update06/04/2020 18:21
      65631John Lawrence HenryPenelope WareCall - Update06/04/2020 18:19
      39445Adrian StuartKatherine BrophyCall - Update06/04/2020 16:19
      110032Jay AtieIzabela MylakCall - Update06/04/2020 16:19

       

       

      'Export Candidates'

       

      CandidateRefCandidate Name
      38731Jason Repeti
      180Simon Parsons
      242John Harris
      243Tim Kirkby
      244Mick Sawford
      245Chris Overton
      246Peter Begbey
      247Paul Mankey
      90770Victor Kingsley
      249Roger Halsey
      250Mark Emberton
      251Les Darrall
      252Derek Jones
      253Phil Thompson

       

       

       

      Hope that makes sense

       

      Thank you!

       

      • v-juanli-msft's avatar
        v-juanli-msft
        Icon for Community Support rankCommunity Support

        Hi HenryJS 

        Check if this result is ok.

        To get this, I create a date table

        date table =
        ADDCOLUMNS (
            CALENDARAUTO (),
            "year", YEAR ( [Date] ),
            "month", MONTH ( [Date] ),
            "week", WEEKNUM (
                [Date],
                2
            ),
            "weekday", WEEKDAY (
                [Date],
                2
            )
        )
        

        Then Create measures

        name =
        LOOKUPVALUE (
            'Export Candidates'[Candidate Name],
            'Export Candidates'[CandidateRef], MAX ( 'Export Actions'[CandidateRef] )
        )
        
        lastMonday =
        CALCULATE (
            MAX ( 'date table'[Date] ),
            FILTER (
                ALL ( 'date table' ),
                'date table'[weekday] = 1
                    && 'date table'[Date]
                        <= TODAY ()
            )
        )
        
        
        Contacted Since Monday =
        IF (
            [name]
                <> BLANK ()
                && MAX ( [action.date] ) <= [lastMonday]
                && MAX ( [ActionName] ) = "Call - Update",
            "Yes",
            "No"
        )
        
        Contact By = IF([Contacted Since Monday]="Yes",MAX([UserName]))
        
        Contacted on = IF([Contacted Since Monday]="Yes",MAX([ActionDate]))
        

        [action.date] is a calculated column

        action.date = [ActionDate].[Date]

         

        Best Regards
        Maggie
        Community Support Team _ Maggie Li
        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.