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
artlemaks
Helper II
Helper II

Report to compare Current Values vs Previous Values based on ID

Hi.

 

I am currently working on a report that I want to add to our dashboard.

 

The report that we are looking for is to compare current value vs previous value by using IDs from the database.

This is what the table looks like

Screenshot_3.jpg
So the ID for current values would be 8027 and for previous values 7995 in the given example. I know this can be achieved with DAX using filtered values, but I haven't been able to find a way to dynamically set the value for the ID for previous values

 

The DAX calculation that I have used is 

 

 

Stock at Cost for 7995 2 = 
CALCULATE(
	SUM('godigitally_easycoun_st view_stocktake_details'[Stock at Cost]),
	'godigitally_easycoun_st view_stocktake_details'[stocktake_id]
		IN { 7995 }
)

 

The value of 7995 is what needs to change. 

 

Is DAX calculation the right way to go, or what is the most efficient way of achieving the results that I'm expecting? 

5 REPLIES 5
Tahreem24
Super User
Super User

@artlemaks ,

Try the below Column:

Previous Record = CALCULATE(SUM(Table[Cost]),FILTER(Table,Table[DateCOlumn]<EARLIER(Table[DateColumn])))

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

@Tahreem24 same problem as above, it is not allowing me to select the Stocktake Date Column as an option for EARLIER() expression. 

Hi @artlemaks ,

 

This works fine on my side.

Column = CALCULATE(MAX('Table'[id]),FILTER('Table','Table'[stock_date]<EARLIER('Table'[stock_date])))

1.PNG

 

Best Regards,

Jay

 

Community Support Team _ Jay Wang

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

@artlemaks , try new columns

last date = maxx(filter(Table, [store_id]= earlier([store_id]) && [stock date] < earlier([stock date])),[stock date])
last value  = maxx(filter(Table, [store_id]= earlier([store_id]) && [stock] = earlier([last Date])),[ID])

Hi @amitchandak .

 

I have tried to create the column as suggested by you using

 

last date = maxx(filter('godigitally_easycoun_st stocktake_master', [store_id]= earlier([store_id]) && [Stocktake Date] < earlier([Stocktake Date])),[Stocktake Date])

 

 But I am getting errors on earlier([store_id]) and earlier([Stocktake Date]). It says

 

Parameter is not the correct type. Cannot find name '[store_id]'.

 

 And same error for Stocktake Date. 

 

Any suggestions?

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

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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