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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
sjrrkb123
Helper III
Helper III

Limiting Aggregation at Different Date Hierarchy Levels

Problem Statement: How to limit the number of values aggregated at a specific date. This date could be calendar date, years, quarters, or months.

Background: I work in a consulting company and our projects with clients are revision based in that on the same project, when the client wants more work, we add a revision rather than starting a new project. So a project could get 50 hours of work in January as revision 0 and another 100 hours of work in May and that would be revision 1. 

Sample Data

Project Code Year Quarter - Year Month Year Revision Number Planned Hours

1A1

 2021 2021-04 2021 October 6 300
1A1 2021 2021-04 2021 October 5 275
1A1 2021 2021-03 2021 September 4 150
1A1 2021 2021-03 2021 August 3 150

1A1

 2021 2021-03 2021 August 2 100
1A1 2021 2021-02 2021 April 1 50
1A1 2021 2021-02 2021 April 0 50


Desired Output:
Case 1: Only Years visible 

Project Code Year 

Planned Hours

1A1 2021 300

 

Case 2: Quarter Year visible

Project Code Quarter - Year  

Planned Hours

1A1 

2021-04

 

300
1A1 2021-03 150
1A1 2021-02 50

 

Case 3: Month Year visible

Project Code Month - Year Planned Hours
1A1 2021 October 300
1A1 2021 September 150
1A1 2021 August 150
1A1 2021 April 50

 

Caveat: the heirarchy values that will be used will be in a bar chart and either years, quarter - years, or month - years will be on the x-axis and this will be used in a measure, not a calculated column.

I am at a loss how to limit the aggregation like this and would appreciate some assistance.

1 ACCEPTED SOLUTION
sjrrkb123
Helper III
Helper III

Between my posting this and now I came up with a great start that uses what you have but also incorporates a disconnected revision number table.

The disconnected table is:

Revision Number Table = DISTINCT('Table'[Revision Number])



MaxPH = 
var max_rev = MAX('Table'[Revision Number])
var slns = 
CALCULATE(SUM('Table'[Planned Hours]),
'Table'[Revision Number] = max_rev)

RETURN
SWITCH(SELECTEDVALUE('Revision Number Table'[Revision Number]),
max_rev, slns, blank())

  
the only issue now is to show the intervening dates as having 0 planned hours.
image.png

 

Basically to have months like 2021 November show as 0 hours.

View solution in original post

5 REPLIES 5
sjrrkb123
Helper III
Helper III

Between my posting this and now I came up with a great start that uses what you have but also incorporates a disconnected revision number table.

The disconnected table is:

Revision Number Table = DISTINCT('Table'[Revision Number])



MaxPH = 
var max_rev = MAX('Table'[Revision Number])
var slns = 
CALCULATE(SUM('Table'[Planned Hours]),
'Table'[Revision Number] = max_rev)

RETURN
SWITCH(SELECTEDVALUE('Revision Number Table'[Revision Number]),
max_rev, slns, blank())

  
the only issue now is to show the intervening dates as having 0 planned hours.
image.png

 

Basically to have months like 2021 November show as 0 hours.

ERD
Community Champion
Community Champion

@sjrrkb123 ,

I don't know the particularities of your data model, couldn't reproduce the issue. Version with blank():

ERD_0-1635198642422.png

If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

ERD
Community Champion
Community Champion

@sjrrkb123 , use 0 instead of blank ().

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

@ERD 
Unfortunately that gives blanks for every period in the calendar table I am using rather than just the intervening periods. 
image.png

 

ERD
Community Champion
Community Champion

@sjrrkb123 , so you need to define most recent planned hours vesrion for defined period (either years, quarter - years, or month - years) ?

You can use a measure:

MaxPH =
VAR mostRecentProjectCode =
    MAX ( 'Table'[Revision Number] )
RETURN
    CALCULATE (
        MAX ( 'Table'[Planned Hours] ),
        'Table'[Revision Number] = mostRecentProjectCode
    )

If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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