Forum Discussion
Using variables to get percent
Hi,
I've had 9 tenants in my apartments from 2024 to 2025. Using Variables, how can I show that in 2025, 57% (4 out of the 7) of the tenants had been evicted, please?
| Tenant | Date_Moved_In | Evicted |
| 1 | 01/10/2024 | Yes |
| 2 | 01/11/2024 | Yes |
| 3 | 01/02/2025 | No |
| 4 | 02/02/2025 | Yes |
| 5 | 03/02/2025 | Yes |
| 6 | 04/02/2025 | Yes |
| 7 | 05/02/2025 | Yes |
| 8 | 06/02/2025 | No |
| 9 | 07/02/2025 | No |
EvictionRate2025 =
VAR Tenants2025 =
FILTER(
'Tenants',
YEAR('Tenants'[Date_Moved_In]) = 2025
)
VAR Total2025 = COUNTROWS(Tenants2025)
VAR Evicted2025 =
COUNTROWS(
FILTER(
Tenants2025,
'Tenants'[Evicted] = "Yes"
)
)
RETURN
DIVIDE(Evicted2025, Total2025, 0) * 100
This returns 57.14% as a numeric value. You can wrap it in FORMAT(..., "0.00%") if you want it styled as a percentage.Hello !
You can use a measure :
Eviction % (2025) = VAR Tenants2025 = CALCULATE( DISTINCTCOUNT('Tenants'[Tenant]), KEEPFILTERS( YEAR('Tenants'[Date_Moved_In]) = 2025 ), REMOVEFILTERS('Tenants'[Evicted]) ) VAR Evicted2025 = CALCULATE( DISTINCTCOUNT('Tenants'[Tenant]), KEEPFILTERS( YEAR('Tenants'[Date_Moved_In]) = 2025 ), 'Tenants'[Evicted] = "Yes" ) RETURN DIVIDE(Evicted2025, Tenants2025)You will find the solution in the pbix file.
5 Replies
- Shahid12523Community Champion
EvictionRate2025 =
VAR Tenants2025 =
FILTER(
'Tenants',
YEAR('Tenants'[Date_Moved_In]) = 2025
)
VAR Total2025 = COUNTROWS(Tenants2025)
VAR Evicted2025 =
COUNTROWS(
FILTER(
Tenants2025,
'Tenants'[Evicted] = "Yes"
)
)
RETURN
DIVIDE(Evicted2025, Total2025, 0) * 100
This returns 57.14% as a numeric value. You can wrap it in FORMAT(..., "0.00%") if you want it styled as a percentage.- RichOBPost Partisan
This is amazing, thank you. Sorry to be a pain, but how would I refer to a financial year if there is a column for that instead of the Date_Moved_In? The financial year is April-March, so the FY2025 result would be 66%.
Tenant Date_Moved_In Evicted Financial_Year 1 01/10/2024 Yes FY2024 2 01/11/2024 Yes FY2024 3 01/02/2025 No FY2024 4 02/04/2025 Yes FY2025 5 03/04/2025 Yes FY2025 6 04/04/2025 Yes FY2025 7 05/04/2025 Yes FY2025 8 06/04/2025 No FY2025 9 07/04/2025 No FY2025
Thanks- ryan_mayuSuper User
you can createa a fy column
Fiscal_Year = if (month('Table'[Date_Moved_In])<4,"FY" & year('Table'[Date_Moved_In])-1, "FY" & year('Table'[Date_Moved_In]))then create the measureMeasure = DIVIDE(CALCULATE(COUNTROWS('Table'),'Table'[Evicted]="Yes"),COUNTROWS('Table'))pls see the attachment below
- AmiraBedhSuper User
Hello !
You can use a measure :
Eviction % (2025) = VAR Tenants2025 = CALCULATE( DISTINCTCOUNT('Tenants'[Tenant]), KEEPFILTERS( YEAR('Tenants'[Date_Moved_In]) = 2025 ), REMOVEFILTERS('Tenants'[Evicted]) ) VAR Evicted2025 = CALCULATE( DISTINCTCOUNT('Tenants'[Tenant]), KEEPFILTERS( YEAR('Tenants'[Date_Moved_In]) = 2025 ), 'Tenants'[Evicted] = "Yes" ) RETURN DIVIDE(Evicted2025, Tenants2025)You will find the solution in the pbix file.
- AmiraBedhSuper User
Put Financial_Year on a slicer or in the visual then use:
Eviction % (FY) = VAR TenantsFY = CALCULATE( DISTINCTCOUNT('Tenants'[Tenant]), REMOVEFILTERS('Tenants'[Evicted]) ) VAR EvictedFY = CALCULATE( DISTINCTCOUNT('Tenants'[Tenant]), 'Tenants'[Evicted] = "Yes" ) RETURN DIVIDE(EvictedFY, TenantsFY)