Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
gumis_rulez
Helper I
Helper I

Problem with measure limits

I want to have a measure which calculates Checkouts YTD - and this works well; and second measure which calculates Checkouts LYTD till the date I have data in fct table.

 

Checkouts = 
CALCULATE(
    COUNT(
        'fct_Hotel Revenue'[Reservation Status Date]
    ),
    'fct_Hotel Revenue'[Reservation Status Key] = 2
)

 

Checkouts YTD = 
VAR _Max = MAX('fct_Hotel Revenue'[Reservation Status Date])

RETURN
CALCULATE(
    [Checkouts],
    DATESYTD(dim_Calendar[Date]),
    dim_Calendar[Date] <= _Max
)

 

Checkouts LYTD = 
VAR _Max = MAX('fct_Hotel Revenue'[Reservation Status Date])

RETURN
CALCULATE(
    [Checkouts YTD],
    SAMEPERIODLASTYEAR(dim_Calendar[Date]),
    dim_Calendar[Date] <= _Max
)

 

The problem is with Checkouts LYTD:

iss_02.JPG

First issue:

For table1 total should be 34480.

For table2 both numbers should be 34480.

 

Second issue:

Secondly the measure should be limited till 14th September. And Checkouts LYTD seems to be taking whole month instead of max calendar from;
For 2018 sales till August: 28146. Sales till 14th September: 2711. All together 30 857. In all above the number should 30 857 instead of 34 480.

 

What am I doing wrong?

 

https://drive.google.com/file/d/1_lyGKrXi-Kpn7AZkk8iu_jfQYOB_N2VC/view?usp=sharing 

 

Pawel

1 ACCEPTED SOLUTION
Selva-Salimi
Super User
Super User

Hi @gumis_rulez 

 

you should update your LYTD measure as follows:

 

Checkouts LYTD =
VAR _Max = MAX('fct_Hotel Revenue'[Reservation Status Date])
VAR LastSaleDatePY = EDATE ( _max, -12 )

RETURN
CALCULATE(
    [Checkouts YTD]
    ,SAMEPERIODLASTYEAR(dim_Calendar[Date]),
    dim_Calendar[Date] <= LastSaleDatePY
)
 
If this post helps, then I would appreciate a thumbs up 👍 and mark it as the solution to help the other members find it more quickly. 

View solution in original post

1 REPLY 1
Selva-Salimi
Super User
Super User

Hi @gumis_rulez 

 

you should update your LYTD measure as follows:

 

Checkouts LYTD =
VAR _Max = MAX('fct_Hotel Revenue'[Reservation Status Date])
VAR LastSaleDatePY = EDATE ( _max, -12 )

RETURN
CALCULATE(
    [Checkouts YTD]
    ,SAMEPERIODLASTYEAR(dim_Calendar[Date]),
    dim_Calendar[Date] <= LastSaleDatePY
)
 
If this post helps, then I would appreciate a thumbs up 👍 and mark it as the solution to help the other members find it more quickly. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.