Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
adnanarain
Helper V
Helper V

Difference of two rows for same column in matrix visual

I am attaching sample data and the desired output. with this data, I am using matrix visual to find number of accounts, Difference, and %. Number of accounts is a simple  count([account Number]) and the difference for row 0 (i.e Date Difference Column) will always be 0 and Row 1 is Account numbers of Row 0 - account numbers of Row 1, in example Account numbers of Row 0 = 3 and Account numbers of Row 1 = 1 so the difference for Row 1 will be 3-1 = 2 and last I want to calculate % for Row 0 the % will be 0 and for Row 1 the formula for % is difference (i.e 2 for Row 1) divided by count of account number for Row 0 (i.e 3) so 2/3 = 67%.

Below is the sample data:

Date Difference        Account Number              Account Open date
012013
022013
032014
022013
032014
032014
142014
152013
162014
272013
282014
292013
3102013
3112014
4122013
4132013
4142014
4152014

 

and below is the desired output, I tried to show for Year 2013 only:

 

 2013                             
Date Difference      Count of account        Difference         %
0300%
11267%
22-1-100%
31150%
42-1-100%

I tried to explain, apologies in advance if anything is not clear.

1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

HI @adnanarain ,

 

 

Create these measures

 

 

Count of Accounts = Count('Table'[Account Number])

 

 

 

Difference = 
var a = CALCULATE([Count of Accounts] , FILTER(ALL('Table'),'Table'[Account Open date] = MAX('Table'[Account Open date]) && 'Table'[Date Difference] = MAX('Table'[Date Difference]) - 1))

RETURN

IF (ISBLANK(a), 0, a - [Count of Accounts])

 

 

 

Percentage = 
var a = CALCULATE([Count of Accounts] , FILTER(ALL('Table'),'Table'[Account Open date] = MAX('Table'[Account Open date]) && 'Table'[Date Difference] = MAX('Table'[Date Difference]) - 1))
RETURN
DIVIDE([Difference],a,0)

 

 

1.jpg

 

 


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

Did I answer your question? Mark my post as a solution!

View solution in original post

1 REPLY 1
harshnathani
Community Champion
Community Champion

HI @adnanarain ,

 

 

Create these measures

 

 

Count of Accounts = Count('Table'[Account Number])

 

 

 

Difference = 
var a = CALCULATE([Count of Accounts] , FILTER(ALL('Table'),'Table'[Account Open date] = MAX('Table'[Account Open date]) && 'Table'[Date Difference] = MAX('Table'[Date Difference]) - 1))

RETURN

IF (ISBLANK(a), 0, a - [Count of Accounts])

 

 

 

Percentage = 
var a = CALCULATE([Count of Accounts] , FILTER(ALL('Table'),'Table'[Account Open date] = MAX('Table'[Account Open date]) && 'Table'[Date Difference] = MAX('Table'[Date Difference]) - 1))
RETURN
DIVIDE([Difference],a,0)

 

 

1.jpg

 

 


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

Did I answer your question? Mark my post as a solution!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors