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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
kovacikm78
Frequent Visitor

Calculate difference of items between date and date of previous occurance

Hi guys,
i would like to ask you for a help.
I have  a callendar table and another table with itemID, date, cathegory and sales.
I would like to show a chart or a table showing by each date change of number of itemIDs to previous occurance.
I am using this measure to count number of items: 

DISTINCTCOUNT('SellingHistory'[itemID])
E.g.: 06-28-2023 I sold 1000 items and previous, on 06-29-2023 I sold none and on 06-30-2023 i sold 1200 items.
On the chart or in the table I want to show by 06-30-2023 number: 20% change
Can someone please help me to create such measure? I would need to show this measure by each cathegory. 
Thank you for your help
3 ACCEPTED SOLUTIONS
Ritaf1983
Super User
Super User

Hi @kovacikm78 

You can achieve your goal with 2 steps (you can  combine them to 1 measure i split it to make simple).

1. calculate the previous date with measure:

previous_Date_units_sold =
if(ISBLANK([Units_Sold]),BLANK(),CALCULATE([Units_Sold],
CALCULATETABLE(LASTNONBLANK('Calendar'[Date],CALCULATE([Units_Sold])),
DATESBETWEEN('Calendar'[Date],MINX(ALL('Calendar'),'Calendar'[Date]),min('Calendar'[Date])-1))))
2. calculate the percantage change
perecent_Change = if (ISBLANK([previous_Date_units_sold]),blank(),[Units_Sold]/[previous_Date_units_sold])
Ritaf1983_0-1688263315056.png

It will also work with slicers

Ritaf1983_1-1688263382096.png

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

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

Hello @Ritaf1983 ,

thx again for your help. I have another question for further adjustement.

Is there a way to aggregate this measure to weeks. Lets say I want to see the percent change to previous week. I have a calendar table with week/year column.
Your help is much appreciated

View solution in original post

Hi @kovacikm78 
Yes, please refer to the linked tutorial:

https://www.youtube.com/watch?v=7_Q5yaU-Fjc

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

5 REPLIES 5
kovacikm78
Frequent Visitor

thank you very much for you help

Happy to assist 😊

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hello @Ritaf1983 ,

thx again for your help. I have another question for further adjustement.

Is there a way to aggregate this measure to weeks. Lets say I want to see the percent change to previous week. I have a calendar table with week/year column.
Your help is much appreciated

Hi @kovacikm78 
Yes, please refer to the linked tutorial:

https://www.youtube.com/watch?v=7_Q5yaU-Fjc

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
Ritaf1983
Super User
Super User

Hi @kovacikm78 

You can achieve your goal with 2 steps (you can  combine them to 1 measure i split it to make simple).

1. calculate the previous date with measure:

previous_Date_units_sold =
if(ISBLANK([Units_Sold]),BLANK(),CALCULATE([Units_Sold],
CALCULATETABLE(LASTNONBLANK('Calendar'[Date],CALCULATE([Units_Sold])),
DATESBETWEEN('Calendar'[Date],MINX(ALL('Calendar'),'Calendar'[Date]),min('Calendar'[Date])-1))))
2. calculate the percantage change
perecent_Change = if (ISBLANK([previous_Date_units_sold]),blank(),[Units_Sold]/[previous_Date_units_sold])
Ritaf1983_0-1688263315056.png

It will also work with slicers

Ritaf1983_1-1688263382096.png

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

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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