Forum Discussion
Searching for values in a table based on another table
- 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 () ) ) ) )
Hi,
Yes that works, but seems a bit clunky to have to write out a Switch statement for each possible specification. I was trying to use a variable (using SELECTEDVALUE as you have) and use that somehow: eg ...FILTER(ModelsSpecs, ModelsSpecs[VARIABLE] <> Blank()
Anyway, thanks for the help. I'll build my giant Switch statement 🙂
The issue with your data is that you have the specs on each column of the models data, that way you cannot do it in a different way since the result needs to be read in a different column each time.
If you had the models spec in a single column that way you could use a single measure to all.
Has you can see in attach file.,