Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
I have a table that lists bookings by location, academic year, financial year, financial week.
I'm trying to count the number of rows for the lastest financial week and year entry.
Booked Rooms 4 = CALCULATE (
COUNTX ( 'Lettings FACT_LettingsWeekly', 'Lettings FACT_LettingsWeekly'[LettingsFactKey] )
,FILTER ( 'Lettings DIM_ReservationType', 'Lettings DIM_ReservationType'[ReservationTypeKey] = 1 )
,FILTER ( 'Lettings FACT_LettingsWeekly', 'Lettings FACT_LettingsWeekly'[FinancialWeek] = [Max Week])
,FILTER ( 'Lettings FACT_LettingsWeekly', 'Lettings FACT_LettingsWeekly'[FinancialYear] = [Max Year])
)
Max Week = MAX('Lettings FACT_LettingsWeekly'[FinancialWeek])
Max Year = MAX('Lettings FACT_LettingsWeekly'[FinancialYear])
you can see here that the total is 374, which is incorrect. It should be 163
When I change the measure to use '33' for week number instead of [Max Week] it's correct.
why is this?
Thanks!
Solved! Go to Solution.
I think you are getting caught by the measures [Max Week] and [Max Year] getting calculated in the context of theCOUNTX iteration. Try it like this, where the value is set outside the iteration and used inside it. Does that help?
Booked Rooms 4 =
VAR _MaxWeek = [Max Week]
VAR _MaxYear = [Max Year]
RETURN
CALCULATE (
COUNTX ( 'Lettings FACT_LettingsWeekly', 'Lettings FACT_LettingsWeekly'[LettingsFactKey] )
,FILTER ( 'Lettings DIM_ReservationType', 'Lettings DIM_ReservationType'[ReservationTypeKey] = 1 )
,FILTER ( 'Lettings FACT_LettingsWeekly', 'Lettings FACT_LettingsWeekly'[FinancialWeek] = _MaxWeek)
,FILTER ( 'Lettings FACT_LettingsWeekly', 'Lettings FACT_LettingsWeekly'[FinancialYear] = _MaxYear)
)
Thats done it 🙂 thank you!
I think you are getting caught by the measures [Max Week] and [Max Year] getting calculated in the context of theCOUNTX iteration. Try it like this, where the value is set outside the iteration and used inside it. Does that help?
Booked Rooms 4 =
VAR _MaxWeek = [Max Week]
VAR _MaxYear = [Max Year]
RETURN
CALCULATE (
COUNTX ( 'Lettings FACT_LettingsWeekly', 'Lettings FACT_LettingsWeekly'[LettingsFactKey] )
,FILTER ( 'Lettings DIM_ReservationType', 'Lettings DIM_ReservationType'[ReservationTypeKey] = 1 )
,FILTER ( 'Lettings FACT_LettingsWeekly', 'Lettings FACT_LettingsWeekly'[FinancialWeek] = _MaxWeek)
,FILTER ( 'Lettings FACT_LettingsWeekly', 'Lettings FACT_LettingsWeekly'[FinancialYear] = _MaxYear)
)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
144 | |
75 | |
63 | |
51 | |
48 |
User | Count |
---|---|
204 | |
86 | |
62 | |
59 | |
56 |