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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
gvenkatesh482
Frequent Visitor

Offset function giving wrong results for first month in X Axis

Hi Community, 

 

Please help me with below . 

 

The requirement is to substract current value and previous value . I used offset and it worked as expected . However, the External filter (Date field ) is returning wrong results for first month(Jan 2022)  and working properly for other months  . Please see screenshots below for reference and also the DAX measure i created. 

 

Date filter is mandatory. At the  same time, Expected value for Jan 2022 is 6.50 , but not 60.94 

DAX measure : 

NetInjectionAVerage =
Var a = Average('X'[level_percentage])
var b= CALCULATE(average( 'X'[level_percentage]),OFFSET(-1,ALLSELECTED('Monthly Calendar Table SCI'[Year Month],'Monthly Calendar Table SCI'[Year Month Number]),orderby('Monthly Calendar Table SCI'[Year Month Number],asc)))
return a-b

Screenshot : 
Screenshot 2023-02-16 092408.jpg
 
Thanks,
G Venkatesh 
4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

The measure can be simplied to

Measure = calculate(Average('X'[level_percentage]),previousmonth('Monthly Calendar Table SCI'[Date]))


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

You are right @AllisonKennedy  . I think i was desperate to try a new DAX expression OFFSET when I designed the measure before . It worked now well with Dateadd . 

 

Thanks for the help . 🙂 

@gvenkatesh482  Glad it worked! Can you mark this as solved please so others can find the solution quickly? 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

AllisonKennedy
Super User
Super User

@gvenkatesh482  Try using ALL instead of ALLSELECTED

 

Also, I think you can achieve the same result using DATEADD instead of OFFSET, provided your date table is marked as a date table. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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