cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Andrea_Jess
Helper III
Helper III

Removing filter context for one row

Hi All, 

 

I have sample data that looks like this n(please see below). What i need to do is create a new column that brings in the values in the Amoutn column, HOWEVER, for the month of Jan-22, the calculation should be Total Location Budget (which is $3,054,444 - this is just a static number) minus the sum of Amount from Jul-21 to Dec-21. 

 

i.e. 3, 054, 444 - 129,715 (129,715 should be the sum of Amount column from Jul21 to Dec21). Then after Jan22, all the values for this fiscal year should be blank. 

 

In my data table, i added in a month num column and created a tag that tags the row as 1 if year = current calendar year (i.e. 2021) and 2 if year = next calendar year (i.e. 2022). I then wrote a If statement that essentially said IF month num = 1 and calendar year num = 2, then total budget - sum of amount otherwise, just return Amount. 

 

But this is being impacted by date at the moment  (i.e. aggregation happening at the month level). How do i remove the filter context only for this one row? 

 

 

Current State

StoreVal TypeMonthAmount
CarinbarBASELINEJul-21166936.9
CarinbarBASELINEAug-21341130.9
CarinbarBASELINESep-21261162
CarinbarBASELINEOct-21175974.6
CarinbarBASELINENov-21175974.6
CarinbarBASELINEDec-21175974.6
CarinbarBASELINEJan-22175974.6
CarinbarBASELINEFeb-22176516.1
CarinbarBASELINEMar-2281013.08
CarinbarBASELINEApr-22226615
CarinbarBASELINEMay-22265871.2
CarinbarBASELINEJun-22267826.7

 

Desired State

StoreVal TypeMonthAmountAmount_Amended
CarinbarBASELINEJul-21166936.9166936.9
CarinbarBASELINEAug-21341130.9341130.9
CarinbarBASELINESep-21261162261162
CarinbarBASELINEOct-21175974.6175974.6
CarinbarBASELINENov-21175974.6175974.6
CarinbarBASELINEDec-21175974.6175974.6
CarinbarBASELINEJan-22175974.62,924,729
CarinbarBASELINEFeb-22176516.1 
CarinbarBASELINEMar-2281013.08 
CarinbarBASELINEApr-22226615 
CarinbarBASELINEMay-22265871.2 
CarinbarBASELINEJun-22267826.7 
1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Andrea_Jess ;

You could create a column or measure.

1.column is below:

Column =
IF (
    YEAR ( [Month] ) = YEAR ( TODAY () ),
    [Amount],
    IF (
        MONTH ( [Month] ) = 1,
        3054444
            - CALCULATE (
                SUM ( [Amount] ),
                FILTER ( ALL ( 'Table' ), [Month] < EARLIER ( 'Table'[Month] ) )
            )
    )
)

2.measure is like below:

Measure =
IF (
    YEAR ( MAX ( [Month] ) ) = YEAR ( TODAY () ),
    SUM ( [Amount] ),
    IF (
        MONTH ( MAX ( [Month] ) ) = 1,
        CALCULATE (
            SUM ( [Amount] ),
            FILTER ( ALL ( 'Table' ), [Month] < MAX ( [Month] ) )
        )
    )
)

The final output is shown below:

vyalanwumsft_0-1636007521404.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yalanwu-msft
Community Support
Community Support

Hi, @Andrea_Jess ;

You could create a column or measure.

1.column is below:

Column =
IF (
    YEAR ( [Month] ) = YEAR ( TODAY () ),
    [Amount],
    IF (
        MONTH ( [Month] ) = 1,
        3054444
            - CALCULATE (
                SUM ( [Amount] ),
                FILTER ( ALL ( 'Table' ), [Month] < EARLIER ( 'Table'[Month] ) )
            )
    )
)

2.measure is like below:

Measure =
IF (
    YEAR ( MAX ( [Month] ) ) = YEAR ( TODAY () ),
    SUM ( [Amount] ),
    IF (
        MONTH ( MAX ( [Month] ) ) = 1,
        CALCULATE (
            SUM ( [Amount] ),
            FILTER ( ALL ( 'Table' ), [Month] < MAX ( [Month] ) )
        )
    )
)

The final output is shown below:

vyalanwumsft_0-1636007521404.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Andrea_Jess , Based on what I got so far.

if you can save your budget on the last date you can access it on all dates using CLOSINGBALANCEYEAR 

 

or

calculate(sum(Target[Budget]), filter(all('Date'), 'Date'[Year] = max('Date'[Year])) )

You can deal with target in a little bit different manner , see if that can help

Distributing/Allocating the Yearly Target(Convert to Daily Target): Measure ( Daily/YTD): Magic of CLOSINGBALANCEYEAR With TOTALYTD/DATESYTD: https://community.powerbi.com/t5/Community-Blog/Power-BI-Distributing-Allocating-the-Yearly-Target-C...

 

Distributing/Allocating the Yearly Target(Convert to Daily Target): https://community.powerbi.com/t5/Community-Blog/Distributing-Allocating-the-Yearly-Target-Convert-to...

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!
!! Subscribe to my youtube Channel !!

Hi Amit, 

 

Thanks for that. I think my issue is mostly around not being able to remove filter context for Jan-22 numbers. 

 

For example, in my column, i want all numbers to be as is, but when we reach Jan-22, i want it to sum up $ amount from Jul21-Dec21. But the issue is that when i put it into a table, it's only summing up for the month of Jan-22 and i want it to sum all values PRIOR to Jan22 (starting from the financial year). 

 

 

@Andrea_Jess , for that datesytd should help, but do you need that for all months ?

example , year-end date 6/30 means year start from 1-jul

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"6/30"))

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!
!! Subscribe to my youtube Channel !!

Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

Power BI Dev Camp Session 22 with aka link 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!