Forum Discussion

chris_PowerBI's avatar
chris_PowerBI
Frequent Visitor
6 years ago
Solved

Calculated Table based on Filter Selection, counting values from another table in the model

I have created a Calculated table called Sector Preferences. The purpose of the table is to display calculations from another data table Occupier Data. The primary column of this table contains a li...
  • v-lid-msft's avatar
    6 years ago

    Hi chris_PowerBI ,

     

    The measure is dynamic but the calculated columns and tables are computed during the database processing and then stored in the model. So In your scenario, we cannot make the calculated column and tables dynamically.

     

    We can use a table visual with your 'Sector Preferences'[Preferences] and following measure as field to meet your requirement:

     

    Measure =
    VAR SELECTED =
        IF ( HASONEVALUE ( Sectors[Sectors] ), VALUES ( Sectors[Sectors] ), "Any" )
    RETURN
        CALCULATE (
            COUNT ( 'Occupier Data'[Out of all of the above Criteria which was of most importance? 1] ),
            FILTER (
                'Occupier Data',
                'Occupier Data'[Out of all of the above Criteria which was of most importance? 1]
                    = IF (
                        HASONEVALUE ( 'Sector Preferences'[Preferences] ),
                        VALUES ( 'Sector Preferences'[Preferences] )
                    )
            ),
            FILTER ( 'Occupier Data', 'Occupier Data'[Sector] = SELECTED )
        )

    Best regards,

    Community Support Team _ Dong Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.