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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
flownfluid
Frequent Visitor

Showing difference between two rows with date selection

Hi all,

 

I have a table like this:

MaterialnumberDateValue
10001.01.2021100
10002.01.2021100
10003.01.2021200


The goal is that the user can select 2 dates and PowerBi show up the difference between the entries per Materialnumber.

 

In example, the user choose Date1 "01.01.2021" and Date2 "03.01.2021" and the result should be:

Materialnumber
100

 

How can I realize this issue, any ideas?

 

Thanks for your help

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@flownfluid , assuming dates are selected in a single  slicer

 

measure =
Var _Min = MINX(allselected('Date'), 'Date'[Date]) //date table assumed
Var _Max = MAXX(allselected('Date'), 'Date'[Date])
return CALCULATE(SUM(Table1[Value]), filter(Table1, Table1[date]=_max)) -CALCULATE(SUM(Table1[Value]), filter(Table1, Table1[date]=_min))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
v-janeyg-msft
Community Support
Community Support

Hi, @flownfluid 

 

If I understand your needs, you can do this:

1. Create a single date list as slicer.

Like this:

Table 2 = DISTINCT('Table'[Date])

2. Create a measure to show the difference.

Like this:

Measure = 
var a=MINX( DISTINCT('Table 2'[Date]),[Date])
var b=MAXX( DISTINCT('Table 2'[Date]),[Date])
var c=SUMX(FILTER(ALL('Table'),[Date]=a&&[Materialnumber]=SELECTEDVALUE('Table'[Materialnumber])),[Value])
var d=SUMX(FILTER(ALL('Table'),[Date]=b&&[Materialnumber]=SELECTEDVALUE('Table'[Materialnumber])),[Value])
return d-c

vjaneygmsft_0-1627381639401.png

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.


Best Regards,

Community Support Team _ Janey

amitchandak
Super User
Super User

@flownfluid , assuming dates are selected in a single  slicer

 

measure =
Var _Min = MINX(allselected('Date'), 'Date'[Date]) //date table assumed
Var _Max = MAXX(allselected('Date'), 'Date'[Date])
return CALCULATE(SUM(Table1[Value]), filter(Table1, Table1[date]=_max)) -CALCULATE(SUM(Table1[Value]), filter(Table1, Table1[date]=_min))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.