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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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