Forum Discussion
Calculations based on Selected Date Selected and set Flags
- 3 years ago
Good Point ...
This is what needs to Happen ...
If we select 31/07/23
For (Out-Properties with Lease End Date as at Financial Year To Date)
We need to count the Number of Properties in the Financial Year to date (EOMRPT) 31/07/23 is Selected ... so that means all properties with a (Lease End Date) betweem 1/07/23 to 31/07/24
For (Out-Properties with Lease End Date in Previous Financial Year)
We need to count the Number of Properties in the Previous Year so if (EOMRPT) = 31/07/23 ... it means all properties with a (Lease End Date) betweem 1/07/22 to 30/06/23
BRAZIL OUT ....:( Vai Portugal 🙂
- 3 years ago
HI Alice_Cooper ,
try the following codes:
Out-Properties with Lease End Date in Previous Financial Year = VAR OPFYYTD = CALCULATE ( DISTINCTCOUNT ( Leases[Property ID] ), FILTER ( ALL ( Leases ), Leases[EOMRPT] <= EOMONTH ( MAX ( EOMRPT[EOMRPT] ), 0 ) && Leases[EOMRPT] >= DATE ( YEAR ( MAX ( EOMRPT[EOMRPT] ) ) - 1, MONTH ( MAX ( EOMRPT[EOMRPT] ) ), 1 ) ) ) RETURN IF ( NOT ( ISBLANK ( OPFYYTD ) ), OPFYYTD, 0 ) Out-Properties with Lease End Date as at Financial Year To Date = VAR OATFY = CALCULATE ( DISTINCTCOUNT ( Leases[Property ID] ), FILTER ( ALL ( Leases ), Leases[EOMRPT] >= EOMONTH ( MAX ( EOMRPT[EOMRPT] ), -1 ) + 1 && Leases[EOMRPT] <= EOMONTH ( DATE ( YEAR ( MAX ( EOMRPT[EOMRPT] ) ) + 1, MONTH ( MAX ( EOMRPT[EOMRPT] ) ), 1 ), 0 ) ) ) RETURN IF ( NOT ( ISBLANK ( OATFY ) ), OATFY, 0 ) - 3 years ago
Hi Alice_Cooper ,
Use the following measure:
Active Houses V1 = COUNTROWS ( CALCULATETABLE ( Leases, Leases[Lease Start Date] <= MAX ( DimDate[End of Month] ), CROSSFILTER ( DimDate[Date], Leases[EOMRPT], NONE ) ) ) - COUNTROWS ( CALCULATETABLE ( Leases, Leases[Effective Lease End Date] <= MAX ( DimDate[End of Month] ), CROSSFILTER ( DimDate[Date], Leases[EOMRPT], NONE ) ) )Using the new measure has bubble size you get:
Thank you Miguel,
It worked ...
Could you help me with the Financial Year One?
I need to get the Financial year from EOMRPT and then get the leases ...
Try Selecting July 2023 in the PowerBi and we will get errors as the code is using lookup...
It seems that you cant use
I tried using:
This function is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules."
Is there anotherway?
ORIGINAL CODE:
I need Help with both Financial Year Measures in the MyTest.Pbix file
Once there are in place, I agree I will not need Flags ...
Thank you in anticipation ... I have been trying to solve it my self but a bit too complicated ... for me....
- MFelix3 years ago
Super User
Hi Alice_Cooper ,
The issue on this two metrics is the end of the lease date since you can have more than one year how do you select the year that you should consider ?
In the example above do you consider 2024 or 2025 or both? be aware that we are selected calendar year 2023.
- Alice_Cooper3 years ago
Helper II
Good Point ...
This is what needs to Happen ...
If we select 31/07/23
For (Out-Properties with Lease End Date as at Financial Year To Date)
We need to count the Number of Properties in the Financial Year to date (EOMRPT) 31/07/23 is Selected ... so that means all properties with a (Lease End Date) betweem 1/07/23 to 31/07/24
For (Out-Properties with Lease End Date in Previous Financial Year)
We need to count the Number of Properties in the Previous Year so if (EOMRPT) = 31/07/23 ... it means all properties with a (Lease End Date) betweem 1/07/22 to 30/06/23
BRAZIL OUT ....:( Vai Portugal 🙂
- MFelix3 years ago
Super User
HI Alice_Cooper ,
try the following codes:
Out-Properties with Lease End Date in Previous Financial Year = VAR OPFYYTD = CALCULATE ( DISTINCTCOUNT ( Leases[Property ID] ), FILTER ( ALL ( Leases ), Leases[EOMRPT] <= EOMONTH ( MAX ( EOMRPT[EOMRPT] ), 0 ) && Leases[EOMRPT] >= DATE ( YEAR ( MAX ( EOMRPT[EOMRPT] ) ) - 1, MONTH ( MAX ( EOMRPT[EOMRPT] ) ), 1 ) ) ) RETURN IF ( NOT ( ISBLANK ( OPFYYTD ) ), OPFYYTD, 0 ) Out-Properties with Lease End Date as at Financial Year To Date = VAR OATFY = CALCULATE ( DISTINCTCOUNT ( Leases[Property ID] ), FILTER ( ALL ( Leases ), Leases[EOMRPT] >= EOMONTH ( MAX ( EOMRPT[EOMRPT] ), -1 ) + 1 && Leases[EOMRPT] <= EOMONTH ( DATE ( YEAR ( MAX ( EOMRPT[EOMRPT] ) ) + 1, MONTH ( MAX ( EOMRPT[EOMRPT] ) ), 1 ), 0 ) ) ) RETURN IF ( NOT ( ISBLANK ( OATFY ) ), OATFY, 0 )