Reply
Highlighted
Frequent Visitor
Posts: 6
Registered: ‎01-19-2017
Accepted Solution

Finding the most recent value

Hi all,


I have survey data with multiple people taking the survey mutiple times.  Each row is a survey response with a date taken. The only way I know which is the "pre survey" and which is the post survey is by the date taken.  I would like to create a "prepost Colunm that read the date and designated pre or post. I have tried a combination of If and Max but I can't seem to get it to work.. Any tips?

Thanks 


Accepted Solutions
Frequent Visitor
Posts: 6
Registered: ‎01-19-2017

Re: Finding the most recent value


Thank you- I see the logic in your approach but I am having trouble with the synax for the "Earlier" section. Per your note, I did the following:
MaxDate = CALCULATE(MAX('Community Leadership Assessment (2)'[Date Talken ], FILTER('Community Leadership Assessment (2)','Community Leadership Assessment (2)'[Name]=EARLIER('Community Leadership Assessment (2)'[Name]))))
But i got this error-A single value for column 'Date Talken ' in table 'Community Leadership Assessment (2)' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
Any thoughts?
CheenuSing wrote:

Hi @LAndes

 

Please try the following

 

1. Create a column called MaxDate

    MaxDate =    

                 CALCULATE(MAX(yourtablename[yourDatecolumn]),FILTER(yourtablename[Name]=EARLIER(yourtablename[Name])))

 

What this does is computes the MaxDate by Name and popluates in all records grouping by Name.

 

2. Create a column called IsLatest

    IsLatest = If([Date]=[MaxDate],"Latest","Older")

 

3. Now create a report with relevant columns from yourtablename and use IsLatest column as a Visual Level Filter filtered for "Latest".

 

Check it out.

 

If it works please accept this as a solution and also give KUDOS.

 

Cheers

 

CheenuSing


 

View solution in original post


All Replies
Senior Member
Posts: 416
Registered: ‎04-21-2016

Re: Finding the most recent value

Hi @LAndes,

Could you post your expression and data structure? So I quickly check it
Frequent Visitor
Posts: 6
Registered: ‎01-19-2017

Re: Finding the most recent value

Sure.. Here is an example:

 

Date Talken NameQ1.Q2Q3Q4
2/23/2016John SmithDisagreeDisagreeNeither agree or disagreeDisagree
2/22/2016John SmithAgreeAgreeAgreeAgree
9/23/2016Jones, NancyAgreeAgreeAgreeAgree
########Jones, RejaNeither agree or disagreeNeither agree or disagreeNeither agree or disagreeNeither agree or disagree
9/22/2016Anderson, ElaineNeither agree or disagreeAgreeAgreeNeither agree or disagree
9/6/2016Anderson, ElaineAgreeNeither Agree or DisagreeDisagreeNeither Agree or Disagree


See the issue?

Senior Member
Posts: 352
Registered: ‎02-17-2016

Re: Finding the most recent value

Hi @LAndes

 

Please try the following

 

1. Create a column called MaxDate

    MaxDate =    

                 CALCULATE(MAX(yourtablename[yourDatecolumn]),FILTER(yourtablename[Name]=EARLIER(yourtablename[Name])))

 

What this does is computes the MaxDate by Name and popluates in all records grouping by Name.

 

2. Create a column called IsLatest

    IsLatest = If([Date]=[MaxDate],"Latest","Older")

 

3. Now create a report with relevant columns from yourtablename and use IsLatest column as a Visual Level Filter filtered for "Latest".

 

Check it out.

 

If it works please accept this as a solution and also give KUDOS.

 

Cheers

 

CheenuSing

Frequent Visitor
Posts: 6
Registered: ‎01-19-2017

Re: Finding the most recent value


Thank you- I see the logic in your approach but I am having trouble with the synax for the "Earlier" section. Per your note, I did the following:
MaxDate = CALCULATE(MAX('Community Leadership Assessment (2)'[Date Talken ], FILTER('Community Leadership Assessment (2)','Community Leadership Assessment (2)'[Name]=EARLIER('Community Leadership Assessment (2)'[Name]))))
But i got this error-A single value for column 'Date Talken ' in table 'Community Leadership Assessment (2)' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
Any thoughts?
CheenuSing wrote:

Hi @LAndes

 

Please try the following

 

1. Create a column called MaxDate

    MaxDate =    

                 CALCULATE(MAX(yourtablename[yourDatecolumn]),FILTER(yourtablename[Name]=EARLIER(yourtablename[Name])))

 

What this does is computes the MaxDate by Name and popluates in all records grouping by Name.

 

2. Create a column called IsLatest

    IsLatest = If([Date]=[MaxDate],"Latest","Older")

 

3. Now create a report with relevant columns from yourtablename and use IsLatest column as a Visual Level Filter filtered for "Latest".

 

Check it out.

 

If it works please accept this as a solution and also give KUDOS.

 

Cheers

 

CheenuSing


 

Senior Member
Posts: 352
Registered: ‎02-17-2016

Re: Finding the most recent value

Hi @LAndes

 

It has to be a column and not a measure.

 

Change it to a column and try again.

 

Cheers

 

CheenuSing

Frequent Visitor
Posts: 6
Registered: ‎01-19-2017

Re: Finding the most recent value

Thanks everyone. I added in a .Date into the formula and it worked. Most appreciative!