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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Oran1234
Frequent Visitor

Need help about dax to find diff

How can I write dax to find diff between above and below amount (93) likes in excel's picture in Power BI?

 

C677F4AC-A9C0-4C6A-8C42-E466239D166D.jpeg

2C3624B5-C9DE-4253-AB57-2226BC58844D.jpeg

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Oran1234,

I created some data:

vyangliumsft_0-1647327479340.png

Here are the steps you can follow:

1. Add Column Index Column From 1.

vyangliumsft_1-1647327479342.png

2. Create calculated column.

diff between above and below =
var _above=CALCULATE(SUM('Table'[production technology]),FILTER(ALL('Table'),'Table'[Index]=EARLIER('Table'[Index])))
var _blew=CALCULATE(SUM('Table'[production technology]),FILTER(ALL('Table'),'Table'[Index]=EARLIER('Table'[Index])-1))
return
IF(_blew=BLANK(),BLANK(),
_above-_blew)

3. Result:

vyangliumsft_2-1647327479343.png

If I have misunderstood your meaning, please provide your desired output and your pbix file without privacy information.

 

Best Regards,

Liu Yang

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

5 REPLIES 5
Anonymous
Not applicable

Hi  @Oran1234,

I created some data:

vyangliumsft_0-1647327479340.png

Here are the steps you can follow:

1. Add Column Index Column From 1.

vyangliumsft_1-1647327479342.png

2. Create calculated column.

diff between above and below =
var _above=CALCULATE(SUM('Table'[production technology]),FILTER(ALL('Table'),'Table'[Index]=EARLIER('Table'[Index])))
var _blew=CALCULATE(SUM('Table'[production technology]),FILTER(ALL('Table'),'Table'[Index]=EARLIER('Table'[Index])-1))
return
IF(_blew=BLANK(),BLANK(),
_above-_blew)

3. Result:

vyangliumsft_2-1647327479343.png

If I have misunderstood your meaning, please provide your desired output and your pbix file without privacy information.

 

Best Regards,

Liu Yang

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

This way is work for the detial that do not in Group.

As I try the result will be below.

画像1.png

 

But when it group it doesn`t work.

 

画像2.png

 

I`m trying to find the way to fix this. If you have any idea, please let me know. 

Yes, It`s work. thank you for your help.

Oran1234
Frequent Visitor

Thank you for your answer. I will make sample data and post it again.

lbendlin
Super User
Super User

Power BI doesn't know what "above" and "below" means.  You need to help it by providing an index column.  Then you can write the DAX you need.

 

Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to work with. Avoid posting screenshots of your source data if possible.

Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.