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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
GouldM
Regular Visitor

Comparing to a 'Previous Category'

Supposing I have data in this table

Category   Value

1                3

2                6

3                7

 

How could I create a measure that DIVIDEs the value of a category but the value of the Previous category

Result would in the above be

Category Value Comparator

1               3       Blank()

2               6       2   (6/3)

3               7       2.16667

 

 

2 ACCEPTED SOLUTIONS
bhanu_gautam
Super User
Super User

@GouldM , Create a measure using

DAX
Comparator =
VAR CurrentCategory = 'Table'[Category]
VAR PreviousCategoryValue =
CALCULATE(
MAX('Table'[Value]),
FILTER(
'Table',
'Table'[Category] = CurrentCategory - 1
)
)
RETURN
IF(
ISBLANK(PreviousCategoryValue),
BLANK(),
DIVIDE('Table'[Value], PreviousCategoryValue)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

@GouldM 

you can try this to create a column

 

Column =
var _last=maxx(FILTER('Table','Table'[category]=EARLIER('Table'[category])-1),'Table'[value])
return if(ISBLANK(_last),blank(),DIVIDE('Table'[value],_last))
11.PNG
or try this to create a measure
 
Measure =
var _last=maxx(FILTER(all('Table'),'Table'[category]=max('Table'[category])-1),'Table'[value])
return if(ISBLANK(_last),blank(),DIVIDE(max('Table'[value]),_last))
12.PNG
pls see the attachment below




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

Proud to be a Super User!




View solution in original post

6 REPLIES 6
Ahmedx
Super User
Super User

v-aatheeque
Community Support
Community Support

Hi @GouldM 

If a community member's response addressed your query, please consider marking it as Accepted Answer and click Yes if you found it helpful.

 

If you have any further questions, feel free to reach out.
Thank you for being a valued member of the Microsoft Fabric Community Forum!

 

Hi none of the answers addressed my problem.

@GouldM 

you can try this to create a column

 

Column =
var _last=maxx(FILTER('Table','Table'[category]=EARLIER('Table'[category])-1),'Table'[value])
return if(ISBLANK(_last),blank(),DIVIDE('Table'[value],_last))
11.PNG
or try this to create a measure
 
Measure =
var _last=maxx(FILTER(all('Table'),'Table'[category]=max('Table'[category])-1),'Table'[value])
return if(ISBLANK(_last),blank(),DIVIDE(max('Table'[value]),_last))
12.PNG
pls see the attachment below




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

Proud to be a Super User!




johnt75
Super User
Super User

You could create a measure like

Comparator =
VAR CurrentValue = SUM( 'Table'[Value] )
VAR PrevValue = CALCULATE(
	SUM( 'Table'[Value] ),
	OFFSET(
		-1,
		ALLSELECTED( 'Table'[Category] ),
		ORDERBY( 'Table'[Category], ASC )
	),
	ALLEXCEPT( 'Table', 'Table'[Category] )
)
VAR Result = DIVIDE( CurrentValue, PrevValue )
RETURN Result
bhanu_gautam
Super User
Super User

@GouldM , Create a measure using

DAX
Comparator =
VAR CurrentCategory = 'Table'[Category]
VAR PreviousCategoryValue =
CALCULATE(
MAX('Table'[Value]),
FILTER(
'Table',
'Table'[Category] = CurrentCategory - 1
)
)
RETURN
IF(
ISBLANK(PreviousCategoryValue),
BLANK(),
DIVIDE('Table'[Value], PreviousCategoryValue)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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