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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Euro0681
Helper II
Helper II

Matrix Subtracting column Values

I have matrix that has dates on columns, which are selected using a slicer and has Sales Amount as a value, and is broken down by Country on the Rows

Euro0681_3-1671580644864.png

Im wanted to create a measure that gives me the 2nd date - 1st date like below

Euro0681_5-1671580803467.png

If anybody could help Please!

2 REPLIES 2
amitchandak
Super User
Super User

@Euro0681 , Assume you are using a measure and only 2 dates are selected

 

then you can switch total using isinscope

 

new measure =
var _max = maxx(allselected(Date),Date[Date])
var _min = minx(allselected(Date),Date[Date])
return

if(isinscope(Date[Date]), [Measure],
calculate( [Measure], filter('Date', 'Date'[Date] =_min )) - calculate( [Measure], filter('Date', 'Date'[Date] =  =_max)) )

 

if they are month

 

 

 

new measure =
var _max = maxx(allselected(Date),Date[Date])
var _min = minx(allselected(Date),Date[Date])
return

if(isinscope(Date[Date]), [Measure],
calculate( [Measure], filter('date',eomonth( 'date'[Date],0) =eomonth(_min,0) )) - calculate( [Measure], filter('date', eomonth('date'[Date],0) = eomonth(_max,0) )) )

When using in the matrix I get something like this

Euro0681_1-1671633532091.png

Not as i expect any suggestion?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

April Fabric Community Update

Fabric Community Update - April 2024

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

March 2024 PBI Gallery Image

Power BI Monthly Update - March 2024

Check out the March 2024 Power BI update to learn about new features.

Top Solution Authors