cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
newtonvr
New Member

how to compare same values in the same column

Hi there!

 

Please see attached screenshot to clarify my needs: 

newtonvr_0-1619087157769.png

 

I'm trying to find the time elapsed between the dateperformed column for each patient, but don't want the time elasped between the dates if the patientIDS aren't the same because that data is irrelevant to me and messes up my visuals. My goal for a new calculated column is, if the patientIDs are the same, return the value in the timelapsedFilterNeg column, and if they are not, return 0. My trouble is I am not sure how to write the formula that says "if the previous value in this column is the same as the next value...".

I am aware that the patientID string is a mixture of numbers and digits, and I have no problem adding a column of only integers to represent the patientID if needed. 

 

Please let me know if I can clarify the issue in any way, thanks!

1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @newtonvr ,

 

Use the index column to create a new index column for each patientID.

new_index = RANKX(FILTER('Table','Table'[id]=EARLIER('Table'[id])),'Table'[index],,ASC)

1.PNG

Then you could compare the value depends on the new index column.

Column = 
var earlier_value = CALCULATE(SUM('Table'[value]),FILTER('Table','Table'[id]=EARLIER('Table'[id])&&'Table'[new_index]=EARLIER('Table'[new_index])-1))
return
IF(ISBLANK(earlier_value),0,'Table'[value]-earlier_value)

2.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

3 REPLIES 3
v-jayw-msft
Community Support
Community Support

Hi @newtonvr ,

 

Use the index column to create a new index column for each patientID.

new_index = RANKX(FILTER('Table','Table'[id]=EARLIER('Table'[id])),'Table'[index],,ASC)

1.PNG

Then you could compare the value depends on the new index column.

Column = 
var earlier_value = CALCULATE(SUM('Table'[value]),FILTER('Table','Table'[id]=EARLIER('Table'[id])&&'Table'[new_index]=EARLIER('Table'[new_index])-1))
return
IF(ISBLANK(earlier_value),0,'Table'[value]-earlier_value)

2.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

amitchandak
Super User IV
Super User IV

@newtonvr , based on what I got, Try a new column like

datediff( maxx(filter(Table, [patientID] = earlier([patientID]) && [Date] < earlier([Date])),[Date]),[Date], day)



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Following your advice, I created a new column with the following formula: 

Column = datediff( maxx(filter(assessment_activity_data, [patientID] = earlier([patientID]) && [dateperformed] < earlier([dateperformed])),[dateperformed]),[dateperformed], day)
 
However, the following photo shows the results:
newtonvr_0-1619095568660.png

 

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Get Ready for Power BI Dev Camp

Power BI Dev Camp - June 24th

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors