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
Anonymous
Not applicable

Filter not affect measure

Hi , 

 

I want to create a measure to calculate the Y-1 value based on the selected Year. 

 

CALCULATE(
SUM(Table[Volumns]),
FILTER(ALL(Table), YEAR(Table[Date]) = SELECTEDVALUE('Calendar'[year]) - 1 && Table[Type] = "type1")
)
 
The above measure works well with fixed value and not affected by any filter. 
But when I add one more filter -- allselected(Table[Category]) to this filter , it can't work.
CALCULATE(
SUM(Table[Volumns]),
FILTER(ALL(Table), YEAR(Table[Date]) = SELECTEDVALUE('Calendar'[year]) - 1 && Table[Type] = "type1" && Allselected(Table[Category]))
)
 
How can I add the silcer filter condition to the formular? 
 
Thanks!
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Icey @amitchandak , 

 

Thank you for your help. 

 

I've fixed it by allexcept function. 

 

CALCULATE(
SUM('Table'[Volumns]),
PREVIOUSYEAR('Table'[Date]),
'Table'[Type] = "type1",
ALLEXCEPT('Table','Table'[Category])
)

View solution in original post

3 REPLIES 3
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Try this:

Measure 2 = 
CALCULATE (
    SUM ( 'Table'[Volumns] ),
    FILTER (
        ALLSELECTED( 'Table' ),
        YEAR ( 'Table'[Date] )
            = SELECTEDVALUE ( 'Calendar'[year] ) - 1
            && 'Table'[Type] = "type1"
    )
)

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @Icey @amitchandak , 

 

Thank you for your help. 

 

I've fixed it by allexcept function. 

 

CALCULATE(
SUM('Table'[Volumns]),
PREVIOUSYEAR('Table'[Date]),
'Table'[Type] = "type1",
ALLEXCEPT('Table','Table'[Category])
)
amitchandak
Super User
Super User

@Anonymous , Do you want year on year. If you have date use time intelligence with date table. If not then have year table

 

With Date or Year table


This Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

 

with date table

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
This year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions


Appreciate your Kudos.

 

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.