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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Comparing Two different dates | PowerBI

hi,

I want to compare two different dates from the same tables

 

Example:

Below is my table

MeterdateCost
ADB12-6-202223.45
ADF12-6-202234.56
Storage12-6-202214.56
ADB12-8-202212
ADF12-8-202223.45
Storage12-8-202245.6

 

I want to compare the cost for these two dates such that my output is like this.

 

MeterPreviousCostNewCost
ADB23.4512
ADF34.5623.45

 

I want to compare dates on the dashboard

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Create a new table for user to select the previous date via PreviousDate = VALUES('Table'[date])

 

Then use this measure to get the values of previous date.

PreviousCost = CALCULATE(SUM('Table'[Cost]),'Table'[date]=SELECTEDVALUE(PreviousDate[date]))
 
Reault:
vchenwuzmsft_0-1654756240281.gif

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

9 REPLIES 9
Anonymous
Not applicable

@v-chenwuz-msft , this really solved my issues, thanks for the solution!!!

Anonymous
Not applicable

hi @amitchandak ,

 

Actually, I want a date filter in the dashboard wherein users can select any 2 days, by which they can compare costs on the selected two days.

Hi @Anonymous ,

 

Create a new table for user to select the previous date via PreviousDate = VALUES('Table'[date])

 

Then use this measure to get the values of previous date.

PreviousCost = CALCULATE(SUM('Table'[Cost]),'Table'[date]=SELECTEDVALUE(PreviousDate[date]))
 
Reault:
vchenwuzmsft_0-1654756240281.gif

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

 

Anonymous
Not applicable

@v-chenwuz-msft , how can I only show the last 3 months dates in the date filter?

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

Those are for creating new measures.

 

Untitled.png

 

Previous cost measure: = 
VAR _latestdate =
    MAX ( Data[date] )
VAR _previousdate =
    CALCULATE ( MAX ( Data[date] ), Data[date] < _latestdate )
VAR _previouscost =
    CALCULATE ( MAX ( Data[Cost] ), Data[date] = _previousdate )
RETURN
    IF ( HASONEVALUE ( Data[Meter] ), _previouscost )

 

New cost measure: = 
VAR _latestdate =
    MAX ( Data[date] )
VAR _latestcost =
    CALCULATE ( MAX ( Data[Cost] ), Data[date] = _latestdate )
RETURN
    IF ( HASONEVALUE ( Data[Meter] ), _latestcost )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

hi @Jihwan_Kim , will this also work if I select two different dates from a filter via dashboard?

Hi,

Thank you for your feedback.

I cannot know without seeing your data model.

Please share your sample pbix file's link here, and then I can try to have a look into it.

Thanks.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

hi @Jihwan_Kim , my table is a single table, with columns meter category, SubscriptionName, date, cost_usd. 

amitchandak
Super User
Super User

@Anonymous , for meausre you can have

 

Last Day Non Continuous = CALCULATE([sales],filter(ALLSELECTED('Date'),'Date'[Date] =MAXX(FILTER(ALLSELECTED('Date'),'Date'[Date]<max('Date'[Date])),'Date'[Date])))

 

or

 

Last Day Non Continuous = CALCULATE([sales],filter(ALLSELECTED('Date'),'Date'[Date] =calculate( max(Sales[Sales Date]), FILTER(ALLSELECTED('Date'),'Date'[Date]<max('Date'[Date])))))

 

 

or refer

Day Intelligence - Last day, last non continous day
https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c3243d1f9

 

Last Day Non Continuous = CALCULATE([sales],filter(ALLSELECTED('Date'),'Date'[Date] =MAXX(FILTER(ALLSELECTED('Date'),'Date'[Date]<max('Date'[Date])),'Date'[Date])))

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.