cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Narender
Resolver I
Resolver I

Last year collection amount on filter selection base

Hi All,

 

I want to calculate the amount of last year if there is no selection in year filter.So in this way it will show 2017 year amount.

But when I will select any other year like 2015 then it should calculate the 2014 year amount.

 

 

I am using this DAX expresion but it is not working as i want:

 

Measure 25 = IF(ISFILTERED(Dates[Year]),
CALCULATE(sum(TAX_TRANSACTION[TAX_SUB_TRANS.AMOUNT]),FILTER(Dates,YEAR(Dates[Date])=YEAR(TODAY())-1))
,
CALCULATE(sum(TAX_TRANSACTION[TAX_SUB_TRANS.AMOUNT]),FILTER(Dates,YEAR(Dates[Date])=YEAR(TODAY())-1)))

 

It is working if i dont select any year  in filter. But not working when i select the any year in year.

 

 

Please guide me to achieve the result.

 

Thanks,

 

Narender

 

2 ACCEPTED SOLUTIONS
v-yulgu-msft
Microsoft
Microsoft

Hi @Narender,

 

Please modify above formula to:

Measure 25 =
IF (
    ISFILTERED ( Dates[Year] ),
    CALCULATE (
        SUM ( TAX_TRANSACTION[TAX_SUB_TRANS.AMOUNT] ),
        FILTER (
            ALL ( TAX_TRANSACTION ),
            YEAR ( TAX_TRANSACTION[Date] )
                = SELECTEDVALUE ( Dates[Year] ) - 1
        )
    ),
    CALCULATE (
        SUM ( TAX_TRANSACTION[TAX_SUB_TRANS.AMOUNT] ),
        FILTER ( Dates, YEAR ( Dates[Date] ) = YEAR ( TODAY () ) - 1 )
    )
)

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

I resolved it by adding month expression with the last year expression in DAX.

 

Narender

View solution in original post

4 REPLIES 4
v-yulgu-msft
Microsoft
Microsoft

Hi @Narender,

 

Please modify above formula to:

Measure 25 =
IF (
    ISFILTERED ( Dates[Year] ),
    CALCULATE (
        SUM ( TAX_TRANSACTION[TAX_SUB_TRANS.AMOUNT] ),
        FILTER (
            ALL ( TAX_TRANSACTION ),
            YEAR ( TAX_TRANSACTION[Date] )
                = SELECTEDVALUE ( Dates[Year] ) - 1
        )
    ),
    CALCULATE (
        SUM ( TAX_TRANSACTION[TAX_SUB_TRANS.AMOUNT] ),
        FILTER ( Dates, YEAR ( Dates[Date] ) = YEAR ( TODAY () ) - 1 )
    )
)

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Can you please guide me?

 

Thanks,

 

Narender

I resolved it by adding month expression with the last year expression in DAX.

 

Narender

HI Yuliana,

 

Thanks for your reply. Its is working now.

 

I want a little modification in this.if possible please tell me below query dax expression.

 

Actually i want  current month amount of last year when no filter is selected .  If user select filter year 2016 then it has to show 2015 year amount of current month.             

 

Thanks,

 

Narender

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors