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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Last values change per category

I have data from UB. They release info twice a week. Highs and Lows for each category (1-2, 2-3...)

 

I have it in excel and I am trying to replicate it on Power BI.
UBUB

 

 

 

 

 

 

For the Change column I tried:

 

Change Previous Day =
VAR PDChange =
CALCULATE (
[Last value],
DATEADD ( 'UB Data'[Date], - 1, day ))
RETURN
[Last value] - PDChange
 
But it didn't work. Any help is appreciated. I've attached the pbix to this message.

 

Urner Barry.pbix

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @Anonymous,

You can try to use the following measure formula to get the difference between current and previous(not continues) based on the current category group:

Change Previous Day =
VAR currDate =
    MAX ( 'UB Data'[Date] )
VAR prevDate =
    CALCULATE (
        MAX ( 'UB Data'[Date] ),
        FILTER ( ALLSELECTED ( 'UB Data' ), [Date] < currDate ),
        VALUES ( 'UB Data'[Size] )
    )
VAR PDChange =
    CALCULATE (
        [Last value],
        FILTER ( ALLSELECTED ( 'UB Data' ), [Date] = prevDate ),
        VALUES ( 'UB Data'[Size] )
    )
RETURN
    [Last value] - PDChange

Regards,

Xiaoxin Sheng

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , Th formula should be like this. Mark calendar as a date table, use period from calendar table in slicer and visual

 

Last value = 
CALCULATE (
    SUM ( 'UB Data'[Price] ),PREVIOUSDAY('Calendar'[Date]))

 

but if the dates are not continuous 

then

 

example

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

 

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

 

 

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

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
Anonymous
Not applicable

I appreciated your time. Thanks.

 

But my issue was not in finding the last day. The dates are not continuous, and I need to find the difference between the last day and the previous day (it varies between 2 and 6 days before). That is where I am struggling.

 

Urner Barry.pbix

Anonymous
Not applicable

HI @Anonymous,

You can try to use the following measure formula to get the difference between current and previous(not continues) based on the current category group:

Change Previous Day =
VAR currDate =
    MAX ( 'UB Data'[Date] )
VAR prevDate =
    CALCULATE (
        MAX ( 'UB Data'[Date] ),
        FILTER ( ALLSELECTED ( 'UB Data' ), [Date] < currDate ),
        VALUES ( 'UB Data'[Size] )
    )
VAR PDChange =
    CALCULATE (
        [Last value],
        FILTER ( ALLSELECTED ( 'UB Data' ), [Date] = prevDate ),
        VALUES ( 'UB Data'[Size] )
    )
RETURN
    [Last value] - PDChange

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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