Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Searching for values in a table based on another table

Hi, I want to populate a table with a count of values based on another table and a filter from a 2nd table. I've tried to replicate using dummy data attached, which is greatly simplified but the log...
  • MFelix's avatar
    MFelix
    5 years ago

    Hi Anonymous ,

     

    That is similar to the one I have the only thing you have here is the fact that you are only doing it for a single spec, if you want to have all the spect you need to use the SWITCH function using your measure you woudl need to redo to something similar to this:

     

    Spec count = 
    CALCULATE (
        SWITCH (
            SELECTEDVALUE ( RequireSpecs[Specification] ),
            "Cruise Control",
                CALCULATE (
                    COUNTROWS ( RequiredModels ),
                    FILTER ( ModelsSpecs, ModelsSpecs[cruise control] <> BLANK () )
                ),
            "Engine Size",
                CALCULATE (
                    COUNTROWS ( RequiredModels ),
                    FILTER ( ModelsSpecs, ModelsSpecs[Engine size] <> BLANK () )
                ),
            "Heated Seats",
                CALCULATE (
                    COUNTROWS ( RequiredModels ),
                    FILTER ( ModelsSpecs, ModelsSpecs[heated seats] <> BLANK () )
                ),
            "No of Doors",
                CALCULATE (
                    COUNTROWS ( RequiredModels ),
                    FILTER ( ModelsSpecs, ModelsSpecs[No of doors] <> BLANK () )
                ),
            "No of Seats",
                CALCULATE (
                    COUNTROWS ( RequiredModels ),
                    FILTER ( ModelsSpecs, ModelsSpecs[No of Seats] <> BLANK () )
                )
        )
    )