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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
newpbiuser01
Helper V
Helper V

Identify differences based on date

Hello,

I have the following data that shows the sales by product for each month:

ProductMonthSales
PencilsNovember10
PensDecember50
PaperJanuary20
TonerFebruary30
PencilsMarch45
PensApril70
PaperMay50
TonerJanuary60
PaperFebruary45
TonerMarch10
PencilsApril10
PensMay5
PaperNovember5
PensMay10

 

I need to flag the differences in the sales by product to get the following: 

ProductPrevious Month (April)Current Month (May)Difference
Pens705-55
Paper05050
Pencils100-10

 

How could I do this? I tried grouping the data by product and month, but I can't figure out how to identify just the products with sales in the current and previous months and also how to show the difference in the sales. 

 

I'd appreciate any help!

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

It is quite easy to solve with the Date and Time Intelligence functions but for that we also need a year column.  If you have that, then please share that column as well.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur , I do have the year as well. So the table would look as follows: 

ProductMonthYearSales
PencilsNovember202210
PensDecember202250
PaperJanuary202320
TonerFebruary202330
PencilsMarch202345
PensApril202370
PaperMay202350
TonerJanuary202360
PaperFebruary202345
TonerMarch202310
PencilsApril202310
PensMay20235
PaperNovember20225
PensMay202310
amitchandak
Super User
Super User

@newpbiuser01 , Create a date using month in case you do not have date

 

Date=  datevalue("01-"&[Month] &"2022")

 

Join the date of your table with date of date table(create a date table) and then use Time Intelligence 

 

Calendar = Addcolumns(calendar(date(2012,01,01), date(2024,12,31) ), "Month no" , month([date])
, "Year", year([date])
, "Month Year", format([date],"mmm-yyyy")
, "Month year sort", year([date])*100 + month([date])
, "Qtr Year", format([date],"yyyy-\QQ")
, "Qtr", quarter([date])
, "Month",FORMAT([Date],"mmmm")
, "Month sort", month([DAte])
, "FY Year", if( Month(_max) <7 , year(_max)-1 ,year(_max))
, "Is Today" ,if([Date]=TODAY(),"Today",[Date]&"")
,"Day of Year" , datediff(date(year([DAte]),1,1), [Date], day)+1
, "Month Type", Switch( True(),
eomonth([Date],0) = eomonth(Today(),-1),"Last Month" ,
eomonth([Date],0)= eomonth(Today(),0),"This Month" ,
Format([Date],"MMM-YYYY") )
,"Year Type" , Switch( True(),
year([Date])= year(Today()),"This Year" ,
year([Date])= year(Today())-1,"Last Year" ,
Format([Date],"YYYY")
)
)

 

example measures

 


MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))

 

 

Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

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

Thanks @amitchandak

 

One more question, if instead of just the sum of sales, I had to identify the differences in a text field - so for sales in May and April in the following table, identify where I had the sales on that product:

 

RegionProductMonthYearSales
EastPencilsNovember202210
WestPensDecember202250
SouthPaperJanuary202320
NorthTonerFebruary202330
EastPencilsMarch202345
WestPensApril202370
SouthPaperMay202350
NorthTonerJanuary202360
EastPaperFebruary202345
WestTonerMarch202310
SouthPencilsApril202310
NorthPensMay20235
EastPaperNovember20225
WestPensMay202310

 

Result:

ProductRegion Sales Last MonthRegion Sales This Month
PenWestNorth, West
PencilsSouth 
Paper South

 

How would I aggregate based on the filtering criteria? I tried the concatenate function but that doesn't work. I'd appreciate any help!

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
https://1drv.ms/u/s!AiUZ0Ws7G26Rh3lMEi3e-7CPs8b6?e=iM85yK

1.png2.pngScreen Capture #1072.png

Helpful resources

Announcements
December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.