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

Max of before the selected month

Good morning
I have a summarized table as follows. 

TWorku_1-1651769805456.png

 

 

I can get the max like this 

Max Opened Accts = MAXX(KEEPFILTERS(VALUES('Summarized Table'[YearMonthTxt]) ),
     CALCULATE(SUM('Summarized Table'[Accounts]) ) )
which is 165 for product 1 and 244 for product 2

The user want to use a date slicer. and when they select lets say Feb 2022, they want to see the max before feb 2022. which is 142 for product 1. 

can someone help me with this task? 

 

1 ACCEPTED SOLUTION
tackytechtom
Super User
Super User

Hi @TWorku ,

 

Maybe this one here, gets you further 🙂

Max Opened Accts = 
VAR _selectedDate =  MAX ( Date[Date] )
RETURN
MAXX (
    'Summarized Table',
    CALCULATE (
        SUM ( 'Summarized Table'[Accounts] ) 
    ),
    REMOVEFILTERS ( 'Summarized Table' ),
    Date[Date] < _selectedDate
)


/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Try this:
(assuming you have a relationship between your Summarize Table and the callendar)

Measure = 

calculate(
Max( Table[Product 1] ),
Table[Date] < max( 'Calendar'[Date] )
)

if you don't have a Date collumn in your Table, and only a YearMonth collumn, there are ways to go around this but I would suggest adding a Date Collumn as per best practice.
tackytechtom
Super User
Super User

Hi @TWorku ,

 

Maybe this one here, gets you further 🙂

Max Opened Accts = 
VAR _selectedDate =  MAX ( Date[Date] )
RETURN
MAXX (
    'Summarized Table',
    CALCULATE (
        SUM ( 'Summarized Table'[Accounts] ) 
    ),
    REMOVEFILTERS ( 'Summarized Table' ),
    Date[Date] < _selectedDate
)


/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

speedramps
Super User
Super User

Hi TWorku

 

Slicers do what they say on the tin. They slice the data !!!

If you slice the date for Feb 2022 then the data will only have  Feb 2022 and you cant aggrrate other months.

 

The solution is to have a detacthed period pick list. (with no relationships)

So when the user clicks the slicer they select a date but do not slicer the data.

 

Max Opened Accts
VAR mypickdate = MIN(picklist[date])
RETURN
CALCULATE(
= MAX(yourtable[value],
     yourtable[date] < mypickdate
)
 
Please click thumbs up and the accept as solution buttons. Thank you ! 😀

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.