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
aatish178
Helper I
Helper I

subtracting previous row value from current row dynamically in Table visual

@quantumudit Hi Udit,I have a below dataset:

 

FYStudentIDStudentNameGenderStatusClassDivision
FY1911palashMAbsentDIV A
FY1912akashMAbsentDIV A
FY1913vikasMAbsentDIV A
FY1914subhasMAbsentDIV A
FY1915kailasMAbsentDIV B
FY1916sureshMAbsentDIV B
FY1917rameshMAbsentDIV B
FY1918ankeshMPresentDIV B
FY1919maheshMPresentDIV B
FY1920pritiFPresentDIV B
FY1921dipaliFPresentDIV B
FY2022abcdFPresentDIV B
FY2023swatiFPresentDIV B
FY2024vaishnaviFPresentDIV B
FY2025akankshaFPresentDIV B
FY2026pallaviFPresentDIV B
FY2027ramaFPresentDIV B
FY2028radhaFPresentDIV B
FY2029sumedhMAdmission CanNA
FY2030shaileshMAdmission CanNA
FY2031venkatMAdmission CanNA
FY2032pandiMAdmission CanNA
FY2033reddeppaMAdmission CanNA
FY2034vishnuMAdmission CanNA
FY2035raviMAdmission CanNA
FY2036kiranFAdmission CanNA
FY2037anupamaFAdmission CanNA
FY2038rehanMOn leaveDIV B
FY2039rijwanMOn leaveDIV B
FY2040akbarMOn leaveDIV C
FY2041atliMOn leaveDIV C
FY2042vetriMOn leaveDIV C
FY2143thomasMWaitingYet to update
FY2144peterMWaitingYet to update
FY2145fredrikMWaitingYet to update
FY2146venkateshMWaitingYet to update
FY2147dineshMWaitingYet to update
FY2148chaitanyaMWaitingYet to update
FY2149rockyMWaitingYet to update

once I loaded this data in PBI then I want to get below output where difference column is actually a difference of count of studentID for each FY: Scenario 1:

 

aatish178_0-1713362740369.png

 

Scenario 2:

aatish178_1-1713362794999.png

Power BI Result:

aatish178_2-1713362890303.png

Here I am suspecting since I have calculated the difference as a calculated column the result is static., I want your help to make it dynamic., I guess with measure that can be possible. can you please help me with measure expression?

 

Kind Regards,

Aatish

 

 

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

Hi @aatish178 

 

First, we need to ensure we have a measure that calculates the total count of StudentID for each FY.

Total Students = COUNT('Table'[StudentID])

 

Next, we'll create a measure that calculates the difference in the count of StudentID between each FY and the previous FY.

Difference = 
VAR CurrentFY = MAX('Table'[FY])
VAR PreviousFY = CurrentFY - 1
VAR CurrentFYCount = CALCULATE([Total Students], 'Table'[FY] = CurrentFY)
VAR PreviousFYCount = CALCULATE([Total Students], 'Table'[FY] = PreviousFY)
RETURN CurrentFYCount - PreviousFYCount
% = 
VAR CurrentFY = MAX('Table'[FY])
VAR PreviousFY = CurrentFY - 1
VAR CurrentFYCount = CALCULATE([Total Students], 'Table'[FY] = CurrentFY)
VAR PreviousFYCount = CALCULATE([Total Students], 'Table'[FY] = PreviousFY)
RETURN (CurrentFYCount - PreviousFYCount)/PreviousFYCount

 

 

This is the result you want:

vjialongymsft_0-1713406478638.png
vjialongymsft_1-1713406486238.png

 

 

Best Regards,

Jayleny

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Do you have a proper Date column?  If no, then do you have a Year and Month column?  Also, from which month does every FY start?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-jialongy-msft
Community Support
Community Support

Hi @aatish178 

 

First, we need to ensure we have a measure that calculates the total count of StudentID for each FY.

Total Students = COUNT('Table'[StudentID])

 

Next, we'll create a measure that calculates the difference in the count of StudentID between each FY and the previous FY.

Difference = 
VAR CurrentFY = MAX('Table'[FY])
VAR PreviousFY = CurrentFY - 1
VAR CurrentFYCount = CALCULATE([Total Students], 'Table'[FY] = CurrentFY)
VAR PreviousFYCount = CALCULATE([Total Students], 'Table'[FY] = PreviousFY)
RETURN CurrentFYCount - PreviousFYCount
% = 
VAR CurrentFY = MAX('Table'[FY])
VAR PreviousFY = CurrentFY - 1
VAR CurrentFYCount = CALCULATE([Total Students], 'Table'[FY] = CurrentFY)
VAR PreviousFYCount = CALCULATE([Total Students], 'Table'[FY] = PreviousFY)
RETURN (CurrentFYCount - PreviousFYCount)/PreviousFYCount

 

 

This is the result you want:

vjialongymsft_0-1713406478638.png
vjialongymsft_1-1713406486238.png

 

 

Best Regards,

Jayleny

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Hi Jayleny,

Thanks the solution is working as expected. The only change I did is I used Right(Max(FY),2) to fetch only number for further subtraction and it worked.

Thanks once again.

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.