Forum Discussion

RichOB's avatar
RichOB
Post Partisan
11 months ago
Solved

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?

 

TenantDate_Moved_InEvicted
101/10/2024Yes
201/11/2024Yes
301/02/2025No
402/02/2025Yes
503/02/2025Yes
604/02/2025Yes
705/02/2025Yes
806/02/2025No
907/02/2025No
  • 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

  • Shahid12523's avatar
    Shahid12523
    Community 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.

    • RichOB's avatar
      RichOB
      Post 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%.

      TenantDate_Moved_InEvictedFinancial_Year
      101/10/2024YesFY2024
      201/11/2024YesFY2024
      301/02/2025NoFY2024
      402/04/2025YesFY2025
      503/04/2025YesFY2025
      604/04/2025YesFY2025
      705/04/2025YesFY2025
      806/04/2025NoFY2025
      907/04/2025NoFY2025


      Thanks

      • ryan_mayu's avatar
        ryan_mayu
        Super User

        RichOB 

        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 measure
        Measure = DIVIDE(CALCULATE(COUNTROWS('Table'),'Table'[Evicted]="Yes"),COUNTROWS('Table'))
         
         
        pls see the attachment below

         

  • 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.

  •  

    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)