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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Trying to create a DAX syntax

I am new in power bi so not exactly sure how to perform this syntax in DAX.

 

I am able to complete the formula in excel which looks like this.

 

IF(A2=A1,0,A2)  So basically I want to know how to get the cell to return the value unless the value above it is the same. 

 

Can someone please help me with how to perform this in DAX syntax? Thank you!

 

WordsCalculation
95649564
546546
1564815648
156480
156480
942942
13541354
13540
13540
948948
9480
10001000
10000
1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

You can't really work with "cells" in Power BI, you have to work with tables and columns. So, you will need to add an index to your table. Then you can filter down to the correct row above your current row, so something along the lines of:

 

Column = 
VAR __lastIndex = [Index]-1
VAR __currentValue = [Words]
VAR __lastValue = MAXX(FILTER(ALL(Table),[Index]=__lastIndex),[Words])
RETURN
IF(_currentValue = __lastValue, 0, __currentValue)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

You can't really work with "cells" in Power BI, you have to work with tables and columns. So, you will need to add an index to your table. Then you can filter down to the correct row above your current row, so something along the lines of:

 

Column = 
VAR __lastIndex = [Index]-1
VAR __currentValue = [Words]
VAR __lastValue = MAXX(FILTER(ALL(Table),[Index]=__lastIndex),[Words])
RETURN
IF(_currentValue = __lastValue, 0, __currentValue)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler 

 

Thank you for your response. I was wondering if you could walk me through how to create an index in my table. Here is a snapshot of my data I am working with. 

 

Capture123.JPG

In Power Query, select your query. Choose Add Column from the menu and then Index Column.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler

 

Thank you for your help! I really appreciate it!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Users online (8,680)