cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GunnerJ
Helper V
Helper V

repeat row value for new column based on filter date

I have a row counter for each row by account. What I'm hoping to do is repeat the max value across all rows as long as that rows date field is less than the date filter. The filter is in the "before" setting. 

 

This is what I currently have but it's just repeating the rows current value. I've also tried the allexcept with just the account in the filter.

MAX ROW = CALCULATE(MAX('MASTER CHARGE ACTIONS'[ROWRANK]),ALLEXCEPT('MASTER CHARGE ACTIONS','MASTER CHARGE ACTIONS'[BI_ACCT],'MASTER CHARGE ACTIONS'[ROWRANK]), FILTER('MASTER CHARGE ACTIONS', 'MASTER CHARGE ACTIONS'[CHG_DATE] <= MAX('Date Table'[Date])))

 

For reference here's a snapshot of one account along with a picture of the slicer. The date table is joined on the CHG_DATE column. The hope is in this example if the date filter is greater than or equal to April 23rd, 2019 to have ALL rows for the account show maxRow of 19 (blue). If the date slicer was on or after April 5th, 2019 but less than the 23rd I'd want all MaxRows to show 11 and so on.

dateslicer.PNG

rowRank.PNG

 

If anything else is needed please let me know and I'll be happy to provide more information.

Thanks in advance!

1 ACCEPTED SOLUTION

This works in your pbix file.

 

MAX ROW = VAR vMAXDATE = MAX('Date Table'[Date])
RETURN CALCULATE(
    CALCULATE(
        MAX('MASTER CHARGE ACTIONS'[ROWRANK]),
        FILTER('MASTER CHARGE ACTIONS', 'MASTER CHARGE ACTIONS'[CHG_DATE] <= vMAXDATE)
    ),
    ALLEXCEPT('MASTER CHARGE ACTIONS','MASTER CHARGE ACTIONS'[BI_ACCT]))

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur @daniel79 

 

Here you go! It's in the state shown in the last picture. 

https://www.dropbox.com/s/fgrcl590zb21xoh/OZARKSGO%202.0.pbix?dl=0

daniel79
Resolver I
Resolver I

Hi, can you try this?

 

MAX ROW = CALCULATE(
    CALCULATE(
        MAX('MASTER CHARGE ACTIONS'[ROWRANK]),
        FILTER('MASTER CHARGE ACTIONS', 'MASTER CHARGE ACTIONS'[CHG_DATE] <= MAX('Date Table'[Date]))
    ),
    ALLEXCEPT('MASTER CHARGE ACTIONS','MASTER CHARGE ACTIONS'[BI_ACCT]))

@daniel79 thanks for the reply!

our solution seems close but the value isn't updating as the date slider moves. It did get the max date across all rows though! In the picture below you can see the date slider only allows up to ROWRANK 9 which I'm hoping would take place of all of the 19s in MAX ROW. Any ideas on how to alter it to enable that functionality?

rowRank2.PNG

This works in your pbix file.

 

MAX ROW = VAR vMAXDATE = MAX('Date Table'[Date])
RETURN CALCULATE(
    CALCULATE(
        MAX('MASTER CHARGE ACTIONS'[ROWRANK]),
        FILTER('MASTER CHARGE ACTIONS', 'MASTER CHARGE ACTIONS'[CHG_DATE] <= vMAXDATE)
    ),
    ALLEXCEPT('MASTER CHARGE ACTIONS','MASTER CHARGE ACTIONS'[BI_ACCT]))

Thank you!

Helpful resources

Announcements
August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 24 without aka link and time 768x460.jpg

Ted's Dev Camp - July 28, 2022

Watch Session 24 of Ted's Dev Camp along with past sessions!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors