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
JoaoTrindade
Frequent Visitor

cumulative by group

Hi,

I'm trying to do a cumulative sum by group. I've tried different solutions but none seems to work.

I have a table with millions of entries of booking made and they all are grouped by channel groupgroup 1.jpg

I was able to create a cumulative sum for the number of nights as in above picture.

The main problem I get is that it does not sum indevidualy per group when all groups are selected. It groups the nights and shows the same value for all.

this is how I'm calculating the cumulative sum

 
cumulative nights = 
CALCULATE([nr_nights total for group],
FILTER(ALLSELECTED('gc_reports bookings'),
'gc_reports bookings'[book_date].[Date]<= MAX ('gc_reports bookings'[book_date].[Date])))

The nr nights total for group is a quick mesure like this

nr_nights total for group = 
CALCULATE(
	SUM('gc_reports bookings'[nr_nights]),
	ALLSELECTED('gc_reports channel_groups'[group])
)

 

Once you select a specific group, all works.

group 2.jpg

Sorry if this is a dumb question but what am I doing wrong here?

 

1 ACCEPTED SOLUTION

@JoaoTrindade here is the measure

 

cumulative nights = 
CALCULATE(
    [total nights],
    FILTER(
        ALLSELECTED('gc_reports bookings'[book_date].[Date]),
        'gc_reports bookings'[book_date].[Date] <= MAX ('gc_reports bookings'[book_date].[Date])
    )
)

also I noticed there is lot of both direction cross filter in your model whcih is a bad idea. anyhow that is seperate topic.

 

 



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.

View solution in original post

15 REPLIES 15
parry2k
Super User
Super User

@JoaoTrindade not sure if you need allselected in this measure

 

nr_nights total for group = 	SUM('gc_reports bookings'[nr_nights])


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.

that filed is a Quick Mesure of total of nights grouped by channel Group. That is the code that comes out of the quick mesure .

@JoaoTrindade did you changed it as I suggested?



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.

I did now but it did did not change anything

test2.jpg

@JoaoTrindade can you share pbix file, remove any sensitive information before sharing.



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 I've posted it here

@JoaoTrindade seems like you missed the link



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 I've edited the reply and it got lost. Sorry for that.

Link

@JoaoTrindade why you are sharing msi file?



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  that goes to show you the state I'm in...  🙂 

I selected the wrong file. Here it is

@JoaoTrindade I think this is what you are looking for, correcT?

 

image.png



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.

@JoaoTrindade here is the measure

 

cumulative nights = 
CALCULATE(
    [total nights],
    FILTER(
        ALLSELECTED('gc_reports bookings'[book_date].[Date]),
        'gc_reports bookings'[book_date].[Date] <= MAX ('gc_reports bookings'[book_date].[Date])
    )
)

also I noticed there is lot of both direction cross filter in your model whcih is a bad idea. anyhow that is seperate topic.

 

 



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 a million Parry! This works to perfection.

@parry2k I was now looking in more detail at the data and the cumulative now it not accounting for the specific booking date selected. It is cumulating for all time. Why is that?

Absolutely! What's the magic trick?

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.