Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Get percentage from two table

Hello,

 

I have the following table, how do I get the percentage from the following table and add a new column in table 1?

Table 1 

OfficeOccupancyIdOccupancyDateOfficeAreaIdSlotsParkingSlotPercentage
AREA1_2021102525-Oct-21AREA115%
AREA1_202109088-Sep-21AREA12%
AREA10_2021101919-Oct-21AREA100%
AREA10_2021102020-Oct-21AREA100%
AREA10_2021102121-Oct-21AREA100%
AREA11_2021102626-Oct-21AREA110%
AREA11_2021102727-Oct-21AREA110%
AREA12_202109088-Sep-21AREA122%
AREA12_202109099-Sep-21AREA122%
AREA14_2021093030-Sep-21AREA1416%
AREA14_202110011-Oct-21AREA142%
AREA15_202110011-Oct-21AREA152%
AREA15_202110022-Oct-21AREA152%
AREA16_2021102525-Oct-21AREA160%
AREA16_2021102626-Oct-21AREA160%
AREA17_2021101313-Oct-21AREA1710%
AREA17_2021101414-Oct-21AREA1710%
AREA18_2021111313-Nov-21AREA1820%
AREA18_2021111414-Nov-21AREA1820%
AREA19_2021101313-Oct-21AREA1910%
AREA19_2021101414-Oct-21AREA199%
AREA6_202110011-Oct-21AREA62%
AREA6_202110022-Oct-21AREA62%

table 2

 

OfficeAreaIdLabelLabelFrOfficeAreaIsDeletedOfficeIdTotalAvailableSlot
AREA8Support areaZone SupportFalseO93
AREA6Marketing areaZone MarketingFalseO110
AREA15Crowded areaZone encombréeFalseO12
AREA14HR areaZone testFalseO92
AREA12Finance areaZone FinanceFalseO110
AREA1Sales areaZone CommerceFalseO114


Thanks

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    You can use USERRELATIONSHIP function to return the values from table 2.

    TotalAvailableSlot from Table2 = CALCULATE(SUM('Table2'[TotalAvailableSlot]),USERELATIONSHIP(Table1[OfficeAreaId],Table2[OfficeAreaId]))

     

    Then you can add DIVIDE function to calculate the percentage.

    ParkingSlotPercentage = DIVIDE(CALCULATE(SUM('Table2'[TotalAvailableSlot]),USERELATIONSHIP(Table1[OfficeAreaId],Table2[OfficeAreaId])),[Slots])

     

    As for the percentage in Table 3 in your new response, how is it calculated?

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

     

8 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Paul,

       

      Thanks for reply my post.

       

      here's the relation table 

       

      is it possible to get the percetage ?
      The idea is like the following :

      OfficeOccupancyIdOccupancyDateOfficeAreaIdSlotsParkingSlotPercentage
      AREA1_2021102525-Oct-21AREA115 94%
      OfficeAreaIdLabelLabelFrOfficeAreaIsDeletedOfficeIdTotalAvailableSlot
      AREA1Sales areaZone CommerceFALSEO114

      (14/15) * 100 =94%

      • Kumail's avatar
        Kumail
        Icon for Impactful Individual rankImpactful Individual

        Hello PaulDBrown 

         

        If you could send sample .pbix that demonstrate what you are looking to get. It would really help providing you a quick solution.
         
        You can send the sample .pbix file by adding it to your drive or dropbox and add the link here. 
         
        Regards
        Kumail Raza

  • PaulDBrown's avatar
    PaulDBrown
    Icon for Community Champion rankCommunity Champion

    For a calculated coloumn in Table 1:

     

    % Occupancy =
    VAR SlotsAvailable =
        CALCULATE (
            SUM ( 'Table 2'[TotalAvailableSlot] ),
            FILTER ( 'Table 2', 'Table 1'[OfficeAreaId] = 'Table 2'[OfficeAreaId] )
        )
    RETURN
        DIVIDE ( SUM ( 'Table 1'[Slots] ), SlotsAvailable )
    
    
    

     

    As a measure:

     

    % Occupancy = 
    DIVIDE(SUM('Table 1'[Slots]), SUM('Table 2'[TotalAvailableSlot]))

     

     

     



     I've attached the sample PBIX file

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Paul,

       

      Thanks for your reply. It's good.

      But there is other table which i'm not aware.

      Table 1 

      OfficeOccupancyIdOccupancyDateOfficeAreaIdSlots 
      AREA1_2021102525-Oct-21AREA115 
      AREA1_202109088-Sep-21AREA12 
      AREA10_2021101919-Oct-21AREA100 
      AREA10_2021102020-Oct-21AREA100 
      AREA10_2021102121-Oct-21AREA100 
      AREA11_2021102626-Oct-21AREA110 
      AREA11_2021102727-Oct-21AREA110 
      AREA12_202109088-Sep-21AREA122 
      AREA12_202109099-Sep-21AREA122 
      AREA14_2021093030-Sep-21AREA1416 
      AREA14_202110011-Oct-21AREA142 
      AREA15_202110011-Oct-21AREA152 
      AREA15_202110022-Oct-21AREA152 
      AREA16_2021102525-Oct-21AREA160 
      AREA16_2021102626-Oct-21AREA160 
      AREA17_2021101313-Oct-21AREA1710 
      AREA17_2021101414-Oct-21AREA1710 
      AREA18_2021111313-Nov-21AREA1820 
      AREA18_2021111414-Nov-21AREA1820 
      AREA19_2021101313-Oct-21AREA1910 
      AREA19_2021101414-Oct-21AREA199 
      AREA6_202110011-Oct-21AREA62 
      AREA6_202110022-Oct-21AREA62 

       

      table 2

       

      OfficeAreaIdLabelLabelFrOfficeAreaIsDeletedOfficeIdTotalAvailableSlot
      AREA8Support areaZone SupportFalseO93
      AREA6Marketing areaZone MarketingFalseO110
      AREA15Crowded areaZone encombréeFalseO12
      AREA14HR areaZone testFalseO92
      AREA12Finance areaZone FinanceFalseO110
      AREA1Sales areaZone CommerceFalseO114

       

      Table 3

      OfficeOccupancyIdUser ID%
      AREA8_20211118A?
      AREA8_20211104B?
      AREA8_20210926A?
      AREA6_20211110A?
      AREA6_20211103A?
      AREA6_20211102A?
      AREA6_20211101C?
      AREA6_20211028D?
      AREA6_20211028C?
      AREA6_20211022E?
      AREA6_20211021B?
      AREA6_20211020A?
      AREA6_20211019C?
      AREA6_20211015C?
      AREA6_20211014B?
      AREA6_20211012D?
      • PaulDBrown's avatar
        PaulDBrown
        Icon for Community Champion rankCommunity Champion

        Sorry, I don´t know what you need from table 3. Can you please clarify?