cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BhoomiT
Frequent Visitor

Difference of Rows

working on a project where I want to create measure/DAX of price difference between brands.Using the following data I want to create the price diffrence between Brand A with All other brands for regions.

Sample data:

Brand Name

Region

Date

Price

A

X

22-09-2021

300

B

X

22-09-2021

320

C

X

22-09-2021

310

A

Y

22-09-2021

330

B

Y

22-09-2021

316

C

Y

22-09-2021

321

A

Z

22-09-2021

337

B

Z

22-09-2021

337

C

Z

22-09-2021

310

D

Z

22-09-2021

302

E

Z

22-09-2021

328

F

Z

22-09-2021

335

3 REPLIES 3
v-xiaotang
Community Support
Community Support

Hi @BhoomiT 

try this 

difference = 
    var _PriceA = CALCULATE(MIN('Table'[Price]),FILTER(ALLSELECTED('Table'),'Table'[Brand Name]="A"))
    var _currPrice = MIN('Table'[Price])
return _currPrice-_PriceA

result

vxiaotang_1-1632814274894.png

vxiaotang_0-1632814205376.png

if you need more help, please @ me.

 

Best Regards,

Community Support Team _Tang

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

amitchandak
Super User
Super User

@BhoomiT , A new column for price of A and then you can take a diff

 

A price = maxx(filter(Table, [region] =earlier( [region] ) && [Brand Name] ="A") , [Price])

 

diff = [Price] -[A price]

 

 

a measure, if needed

 

A price = maxx(filter(allselected(Table), [region] =max( [region] ) && [Brand Name] ="A") , [Price])

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

Thank You Amit,

 

This is working perfact up to region level filters but, when I tried to calculate it at branch and terittory level ( level down the region) then there is minor deviation in the calculation. 

 

request you to please guide me how can I calculate a measure so that it works for region, branch, terittory filters as well as time filters.

Helpful resources

Announcements
Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Power BI Womens Summit 2021 768 x460.jpg

Interviews, learning sessions, allies, and more!

#PowerBIWomenSummit

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!