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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Prima_
Resolver I
Resolver I

Difference between last two months data

Hi,

 

I have a measure (diff instead of sum in total) to compute the difference between last two months Error Free %

It works but takes time since the data set is huge. Is there any efficient way of doing this?

 

Measure:
diff instead of sum in total =
Var _TM= Max([prev_monthyear_num])
Var _LM = _TM - 1
Var _ThisMonthV = CALCULATE([% Error Free], 'FINAL'[prev_monthyear_num] = _TM)
Var _PrevMonthV = Calculate([% Error Free],'FINAL'[prev_monthyear_num]=_LM)
return CALCULATE( _ThisMonthV - _PrevMonthV)

------------------------

column:
prev_monthyear_num = [Year 1]*100 + [Month 1] -1

------------------------

Measure:
% Error Free = 1 - ('FINAL'[Count of Error] /'FINAL'[Count of Products] )

 

Thanks.

2 REPLIES 2
lbendlin
Super User
Super User

Your approach will only work from February to December.  To cover the scenario for January you need to find the penultimate yearmonth value, rather than trying to subtract 1.

v-zhangti
Community Support
Community Support

Hi, @Prima_ 

 

Can you provide sample data for testing? Sensitive information can be removed in advance. What kind of expected results do you expect? You can also show it with pictures or Excel. I look forward to your response.

 

Best Regards,

Community Support Team _Charlotte

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

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.