Forum Discussion
Anonymous
7 years agoNot applicable
Calculating Patient Weight Loss between First and last date
Hi,
I am very new to all things Power BI. So any help and patience is appreciated.
I am trying to calculate the weight loss for my clients between first and last visits.
I have a table that contains patient ID, weight, test date.
| ID | Weight | Test Date |
| 31017 | 131 | Wednesday, October 18,2017 |
| 31017 | 136 | Wednesday, September 20, 2017 |
Is a 'New Measure' the best way to do this?
Thanks in advance.
Hi Anonymous ,
If you have multi IDs, then we can create a measure as below.
Measure = VAR mind = MIN ( 'Table'[Test Date] ) VAR maxd = MAX ( 'Table'[Test Date] ) VAR maxv = CALCULATE ( SUM ( 'Table'[Weight] ), FILTER ( 'Table', 'Table'[Test Date] = maxd ) ) VAR minv = CALCULATE ( SUM ( 'Table'[Weight] ), FILTER ( 'Table', 'Table'[Test Date] = mind ) ) RETURN maxv - minv
2 Replies
- Zubair_Muhammad
Community Champion
Anonymous
Try this MEASURE
Measure = VAR Start_ = MIN ( Table1[Test Date] ) VAR End_ = MAX ( Table1[Test Date] ) RETURN CALCULATE ( MAX ( Table1[Weight] ), Table1[Test Date] = End_ ) - CALCULATE ( MAX ( Table1[Weight] ), Table1[Test Date] = Start_ ) - v-frfei-msft
Community Support
Hi Anonymous ,
If you have multi IDs, then we can create a measure as below.
Measure = VAR mind = MIN ( 'Table'[Test Date] ) VAR maxd = MAX ( 'Table'[Test Date] ) VAR maxv = CALCULATE ( SUM ( 'Table'[Weight] ), FILTER ( 'Table', 'Table'[Test Date] = maxd ) ) VAR minv = CALCULATE ( SUM ( 'Table'[Weight] ), FILTER ( 'Table', 'Table'[Test Date] = mind ) ) RETURN maxv - minv