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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Roinka01
New Member

Accumulating count

Hi there,

I am using a line and stacked column chart.

I would like to present for every month the total count of events created so far (not just for this month but everything until this month).

e.g. Jan - 10 events, Feb - 20, March - 15.

Then i would like to see on the graph on Jan - 10, on Feb 30, On March 45 and so on.

On the shared axis i have the first day of the month (which is a date taken from table Calendar defind at the DB).

At column values i have a measure called - NoOfEvents.

My measure is defined as  NoOfEvents=CALCULATE(DISTINCTCOUNT(MyTable[event_id]), Filter(table2, some filter))

The problem is that i can see the count per month and not the accumulated count per month. So insetad of seeing all the events untill this month i can only see the events created on that month.

I get Jan - 10 events, Feb - 20, March - 15.

instead of 

Jan - 10, on Feb 30, On March 45

Please advise how shold i change my measure to get the accumulated count?

Thank you

6 REPLIES 6
parry2k
Super User
Super User

@Roinka01 I have answered the similar question at this post

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos 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.

Are you refering to this code:

SUMX(FILTER(ALLSELECTED('Calendar'[Date]), 'Calendar'[Date]<= MAX('Calendar'[Date])),CALCULATE(DISTINCTCOUNT(TimeLog[Rig_Name])))

can you explain it?

Not sure how to translate it to my example.

 

@Roinka01 As a best practice, add date dimension in your model and use it for and time intelligence calculations. Once the date dimension is added, mark it as a date table on table tools.

https://perytus.com/2020/05/22/create-a-basic-date-table-in-your-data-model-for-time-intelligence-ca...

 

After you add date dimension and added relationship with your table, the following expression will work.

 

Running Total = 
SUMX(
FILTER(
ALLSELECTED('Calendar'[Date]), --this is new calendar/date dimension you add to the model
'Calendar'[Date]<= MAX('Calendar'[Date])
),
CALCULATE(DISTINCTCOUNT(TimeLog[Rig_Name]))) --this will your table name and column name

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos 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.

Thank you but i am afraid it doesnt work. 😞

Also i dont understand it.

SUMX should be used when we are performing some formula over more than a single column all along the rows. But here we are only counting over a single column.

@Roinka01 not sure why it is not working. and if you simply answer that it is not working, I don't know how I can help further. You have to share what measure you added, what result you are getting? Are there any filters. Provide as much detail as you can otherwise we will keep on going in circles.



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.

Hi,

sorry for the delay i had to leave office.

the measure is:

SumOfTotTv = sumx(filter(ALLSELECTED('Calendar'[FirstDayOfMonth]) , 'Calendar'[FirstDayOfMonth]<MAX('Calendar'[FirstDayOfMonth])),CALCULATE(DISTINCTCOUNT('Calendar'[FirstDayOfMonth])))

and what i get is (while i have tens of thoussands of such events):

 

Roinka01_0-1593338743882.png

 

Thanks for your help.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.