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

Why my measure can't be filtered ?

Hi everyone, 

 

I'm working on a table which contains informations about some orders and I want to display in a visual the sum of the current year sales and the sum of the previous year sales. Classic problem I guess, so I looked on internet and found a lot of topics for this but all were working with dates. However, In my tables the year is stored as an integer (ex: 2023, 2022...). So I built my own measure which works pretty well, I can obtain the annual sales for the year before the one selected in my slicer:

 

previous = 
VAR PY =
    SELECTEDVALUE(Clients[InvoiceYear]) - 1
RETURN
    CALCULATE (
        [Sum of sales],
        FILTER (
            ALL ( Orders ),
            Orders[InvoiceYear] = PY
        )
    )

 

 

(I want to filter my data on the invoice year of the table Clients.)

 

But now I'm facing another problem : this measure can't be filtered. When I want to display it in a table with clients codes (stored in Clients table) for example, the value of the total year sales is displayed in each row and I'm not able to have the year sales by client and I really don't understand why. 

 

Did someone can help me please ?

 

Best regards, 

Clément

1 ACCEPTED SOLUTION
eliasayyy
Memorable Member
Memorable Member

 

previous = 
VAR PY =
    MAX(Clients[InvoiceYear]) - 1
RETURN
    CALCULATE (
        [Sum of sales],
            REMOVEFILTERS([column with slicer]),
            Orders[InvoiceYear] = PY
    )

 

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

@clementalba Maybe:

previous = 
VAR PY =
    SELECTEDVALUE(Clients[InvoiceYear]) - 1
VAR ClientCode = MAX('Clients'[Code])
RETURN
    CALCULATE (
        [Sum of sales],
        FILTER (
            ALL ( Orders ),
            Orders[Client Code] = ClientCode,
            Orders[InvoiceYear] = PY
        )
    )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
eliasayyy
Memorable Member
Memorable Member

 

previous = 
VAR PY =
    MAX(Clients[InvoiceYear]) - 1
RETURN
    CALCULATE (
        [Sum of sales],
            REMOVEFILTERS([column with slicer]),
            Orders[InvoiceYear] = PY
    )

 

Works great, thank you @eliasayyy !

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.