cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
merelvstr
Helper I
Helper I

Filtering rows with LY Measure

Hi all!

 

It feels like I am missing something very simply, but I just can't figure it out.

 

I have a simple last year measure for Revenue that works perfectly well all the time:

 
LY Revenue =
CALCULATE(
    [CY Revenue],
    SAMEPERIODLASTYEAR('Dropoff Date'[Date]))
 
Of which CY Revenue is the following:
CY Revenue =
    SUMX(RAReporting,
            [Total Bill]
            -[Total Bill Tax 3]
            -[Damage]
            -[Fines]
            -[Admin Fee])
 
Now, when I want to filter the LY Revenue for short term rows only, I have the following measure:
 
LY Revenue (Short Term Only) =
CALCULATE(
    [LY Revenue],
    FILTER(RAReporting,RAReporting[LT/ST In RAReport]="Short Term"))
 
I get blanks in my table which has external filters active for my date table:
- Year: 2019
- Month: Jul
y
 
Can anyone help me how to get the right measure for LY Revenue filtered for Short Term?
 
PS. When I use a filter on the page for Short Term, it does work perfectly, but in the measure it doesnt work.
 
Thanks a lot!
Regards,
Merel
1 ACCEPTED SOLUTION
Anonymous
Not applicable

First of all, I don't know what's going on since I can't see the model. Second of all, YOU SHOULD NOT USE EXPANDED TABLES IN FILTERS. This is dangerous and slows down execution big time. Change the measures to:

 

LY Revenue =
	CALCULATE(
	    [CY Revenue],
	    SAMEPERIODLASTYEAR('Dropoff Date'[Date]) -- Is 'Dropoff Date' your Date table?
	)

CY Revenue =
    SUMX(
    	RAReporting,
        RAReporting[Total Bill]
        - RAReporting[Total Bill Tax 3]
        - RAReporting[Damage]
        - RAReporting[Fines]
        - RAReporting[Admin Fee]
     )
 
LY Revenue (Short Term Only) =
	CALCULATE(
	    [LY Revenue],
	    KEEPFILTERS( RAReporting[LT/ST In RAReport] = "Short Term" )
	)

Please stick to the rule: column names MUST BE preceded with the name of the table but measures MUST NOT.

 

Best

Darek

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

First of all, I don't know what's going on since I can't see the model. Second of all, YOU SHOULD NOT USE EXPANDED TABLES IN FILTERS. This is dangerous and slows down execution big time. Change the measures to:

 

LY Revenue =
	CALCULATE(
	    [CY Revenue],
	    SAMEPERIODLASTYEAR('Dropoff Date'[Date]) -- Is 'Dropoff Date' your Date table?
	)

CY Revenue =
    SUMX(
    	RAReporting,
        RAReporting[Total Bill]
        - RAReporting[Total Bill Tax 3]
        - RAReporting[Damage]
        - RAReporting[Fines]
        - RAReporting[Admin Fee]
     )
 
LY Revenue (Short Term Only) =
	CALCULATE(
	    [LY Revenue],
	    KEEPFILTERS( RAReporting[LT/ST In RAReport] = "Short Term" )
	)

Please stick to the rule: column names MUST BE preceded with the name of the table but measures MUST NOT.

 

Best

Darek

View solution in original post

Hi Darek,

 

Using KEEPFILTERS() works perfectly as you suggested! Thank you so much!

'Dropoff Date' is indeed my date table.

 

I am not sure I understand what you mean with your two warnings of not using expanded tables in filters or using column names in measures, or where I have done either of these, but I will look up these topics online to prevent future mistakes. But thank you for the warning!

 

I am super happy with the solution!

 

Thanks

Merel

 

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.