cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
susan_d_10
Regular Visitor

How to determine a change in value for an attribute over a time period

I am very new to this, so i am hoping my explanation makes sense.       I am trying to show the monthly variance of a part attribute.    This attribute is not a measure but just a number and there can be daily records in the cube.      I am using Live Connection   For EOM processing a flag is set to indicate that the value on the last day of the month against the part is that month's value.    I am trying to get something like this below, so i can show any variances.    I have very limited experience with DAX and tried PREVIOUSMONTH but this will only let me SUM the number value.   I need only the one value that has the EOM processing flag against it.   Any ideas would be great, so far i have spent a number of days on this.

 

Part            Current Mth        Previous Mth      % Diff

widget 1     5.5                       4.5                       18%

6 REPLIES 6
Super User IV
Super User IV

Re: How to determine a change in value for an attribute over a time period

If you have a calendar, datesmtd and toyalmtd can help. Option 2 and 3, is the one work for you

// MTD and LMTD
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 MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))

// MTD and LMTD, if you have month end filter

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]),Sales[EOM]=1)
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)),Sales[EOM]=1)
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))),Sales[EOM]=1)

// MTD and LMTD, filter for month end
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),filter('Date','Date'[Date]=endofmonth('Date'[Date])))
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),filter('Date','Date'[Date]=endofmonth(dateadd('Date'[Date],-1,MONTH))))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/





Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
In case it does not help, please provide additional information and mark me with @
My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP,
HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Super User! Linkedin


Super User IV
Super User IV

Re: How to determine a change in value for an attribute over a time period

Hmm, if this is a LIVE connection, I am not certain that time intelligence functions are supported. I know they are not for Direct Query and I *think* this also covers Live connections. If that is indeed the case, See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


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

Not the Power BI thought police...

I have NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

susan_d_10
Regular Visitor

Re: How to determine a change in value for an attribute over a time period

Thank you for this.  As soon as i use CALCULATE(SUM.....) it is summing up the values for the entire month.    there is a part price every day of the month the only value that i need is the price that has EOM snapshot flag set to Y.   I am very new at this and trying to work out how to attach an excel file.   But sample below. 

Snapshot DateEOM Snapshot FlagPartPrice     
31/01/2020YWidget111 Sample   
23/01/2020NWidget111.75 Jan   
15/01/2020NWidget111.75 PartCurr MthPrev MthDiff
10/01/2020NWidget111.25  JanDec 
9/01/2020NWidget111.25 Widget 11111.54.50%
8/02/2020NWidget111.25 Widget27.7579.60%
7/02/2020NWidget111.25     
6/02/2020NWidget111.25     
5/02/2020NWidget111.25     
4/02/2020NWidget111.25     
3/02/2020NWidget111.5     
2/02/2020NWidget111.5     
1/02/2020NWidget111.5     
31/12/2019YWidget111.5     
25/02/2020NWidget27     
Super User IV
Super User IV

Re: How to determine a change in value for an attribute over a time period

@susan_d_10 

I think sample do not have enough data for Widget two. Please find solution attached(Link below signature)





Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
In case it does not help, please provide additional information and mark me with @
My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP,
HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Super User! Linkedin


susan_d_10
Regular Visitor

Re: How to determine a change in value for an attribute over a time period

Thank you very much.    This is so close.   It works on the data provided and that may be my mistake.   On our data the MAX is making it return the highest number, not the number that was the last at EOM.    I will keep working with these and i am sure i will crack it.

susan_d_10
Regular Visitor

Re: How to determine a change in value for an attribute over a time period

I have tried all of these but to no avail.     No matter what i do with the CALCULATE i immediately get every day's price, instead of only the one that is the EOM figure

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors