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
Dunner2020
Post Prodigy
Post Prodigy

Running total by the end of last month

Hi there,

 

I have a measure that calculates the running total until the last month. My measure looks like as follow:

 

Running total  =
var CurrentDate = MAX('Table'[Start Date ])
Var lastmonth =EOMONTH(TODAY(),-1)
Return
sumx(
filter(ALL('Table'),'Table'[Start Date]<=CurrentDate && 'Table'[Start Date] <=lastmonth ),  [calculated-value])
 
When I displayed the calculated measure on the graph it looks like as follow:
 

Screenshot 2021-01-18 105600.png

 

I was expecting the measure to plot the graph until December. However, it plotted the graph of the current month i.e. January. Could anyone guide me where I made the mistake?

 
1 ACCEPTED SOLUTION

Here is my updated measure:

Running Total = 

var CurrentDate = MAX('Table'[Start Date])
Var lastmonth =EOMONTH(TODAY(),-1)

Return
IF(CurrentDate <=lastmonth,
sumx(
filter(ALL('Table'),'Table'[Start Date)]<=CurrentDate),
[calculated-value])
)

View solution in original post

10 REPLIES 10
parry2k
Super User
Super User

@Dunner2020 that's your problem, you are mixing dates, showing the x-axis from the date table, and doing the measure on fact table date column. change the date in your measure from your date table and it should work.

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals to get a summary of my favourite Power BI feature releases in 2020

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Dunner2020 also can you share the updated measure you are currently using?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Here is my updated measure:

Running Total = 

var CurrentDate = MAX('Table'[Start Date])
Var lastmonth =EOMONTH(TODAY(),-1)

Return
IF(CurrentDate <=lastmonth,
sumx(
filter(ALL('Table'),'Table'[Start Date)]<=CurrentDate),
[calculated-value])
)
parry2k
Super User
Super User

@Dunner2020 do you have a separate date table in your model? I'm a bit lost. 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Yes. I have separate date table in my model which is connected to the fact table. 

parry2k
Super User
Super User

@Dunner2020 weird, do you have data for December 2020? Also what you are using on x-axis?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k , Yes I got the data for December. The last date for December is 28-12-2020. the x-axis contains the Month name which comes from the Date Table.

parry2k
Super User
Super User

@Dunner2020 this is what you need to do in your measure, in fact, you are filtering your table in sumx but what that is doing just not adding the value of the current month in this case it is Jan 2021, but it is still returning the value for Jan 2021 up to Dec 2020, update your measure like this:

 

Running total  =
var CurrentDate = MAX('Table'[Start Date ])
Var lastmonth =EOMONTH(TODAY(),-1)
Return
IF (CurrentDate <= lastmonth,
sumx(
filter(ALL('Table'),'Table'[Start Date]<=CurrentDate  ),  [calculated-value])
)

 

Having said that, as a best practice you always want to add a date dimension in your model and perform time intelligence calculation based on this date dimension. There are many posts on how to add this dimension table, you can check my post on it there.

 

Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k Thanks for the reply. I tried your recommended measure. Now the gaph shows data upto November month only as shown in the figure

leo_89_0-1610923432464.png

 

aj1973
Community Champion
Community Champion

Hi @Dunner2020 

Well you called your measure Var lastmonth =EOMONTH(TODAY(),-1) to summit untill today. TODAY() in that function id the day of the current month. There is no mistake however if you don't want to see January of this year then select the graph and use the filter pane to fiter out the 2021 year.

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

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.