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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
GabrielGreg
New Member

Analysis of Cost

Good morning.

 

I have a question on how I can calculate the difference between values of a product in different months, for analysis of cost reduction or an increase.

 

Thank you very much for your attention.

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @GabrielGreg 

According to your description, you want to "calculate the difference between values of a product in different months". I have no sample data so i create some test data in my side , you can refer to i hope it can help you.

(1)This is my test data:

vyueyunzhmsft_0-1684375503333.png

(2)We can create two date table as slicers and we do not need to create ant relationship between the tables.

We can click "New Table" and enter this:

Date = ADDCOLUMNS( CALENDAR(FIRSTDATE('Table'[Date]) , LASTDATE('Table'[Date])) ,"Year" , YEAR([Date]) ,"Month" , MONTH([Date]))
Date 2 = ADDCOLUMNS( CALENDAR(FIRSTDATE('Table'[Date]) , LASTDATE('Table'[Date])) ,"Year" , YEAR([Date]) ,"Month" , MONTH([Date]))

(3)Then we can create three measures like this:

Left_Slicer = var _t = FILTER('Table' , YEAR('Table'[Date]) =  MAX('Date'[Year])  && MONTH('Table'[Date]) = MAX('Date'[Month]))
return
SUMX(_t , [Value])
Right_Slicer = var _t = FILTER('Table' , YEAR('Table'[Date]) =  MAX('Date 2'[Year])  && MONTH('Table'[Date]) = MAX('Date 2'[Month]))
return
SUMX(_t , [Value])
Differences = [Right_Slicer] - [Left_Slicer]

 

(4)Then we can put the fields we need on the visual and we can select the slicer to select the months we need to compare and then we can get the differnece in the table visual:

vyueyunzhmsft_1-1684375628249.png

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

1 REPLY 1
v-yueyunzh-msft
Community Support
Community Support

Hi , @GabrielGreg 

According to your description, you want to "calculate the difference between values of a product in different months". I have no sample data so i create some test data in my side , you can refer to i hope it can help you.

(1)This is my test data:

vyueyunzhmsft_0-1684375503333.png

(2)We can create two date table as slicers and we do not need to create ant relationship between the tables.

We can click "New Table" and enter this:

Date = ADDCOLUMNS( CALENDAR(FIRSTDATE('Table'[Date]) , LASTDATE('Table'[Date])) ,"Year" , YEAR([Date]) ,"Month" , MONTH([Date]))
Date 2 = ADDCOLUMNS( CALENDAR(FIRSTDATE('Table'[Date]) , LASTDATE('Table'[Date])) ,"Year" , YEAR([Date]) ,"Month" , MONTH([Date]))

(3)Then we can create three measures like this:

Left_Slicer = var _t = FILTER('Table' , YEAR('Table'[Date]) =  MAX('Date'[Year])  && MONTH('Table'[Date]) = MAX('Date'[Month]))
return
SUMX(_t , [Value])
Right_Slicer = var _t = FILTER('Table' , YEAR('Table'[Date]) =  MAX('Date 2'[Year])  && MONTH('Table'[Date]) = MAX('Date 2'[Month]))
return
SUMX(_t , [Value])
Differences = [Right_Slicer] - [Left_Slicer]

 

(4)Then we can put the fields we need on the visual and we can select the slicer to select the months we need to compare and then we can get the differnece in the table visual:

vyueyunzhmsft_1-1684375628249.png

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.