Forum Discussion
MarkDGaal
10 years agoHelper III
Custom M Script to sum values from Joined/Merged Queries
Hi guys heres what i'm trying to accomplish.... My data structure Table1: ID#| Capability.1 | Capability.2 | Capability.3| .... 37 total Capability.# columns
97 | Crawl | Walk |...
MarkDGaal
10 years agoHelper III
Here is what I would write in SQL to do the same....
select t1.ID, t1.Capability.1, t1.Capability.2, t1.Capability.3
,t2.[Vehicle1Score]
+ case when t3.[Vehicle1Score] is null then 0 else t3.[Vehicle1Score] end
+ case when t4.[Vehicle1Score] is null then 0 else t4.[Vehicle1Score] end as [Vehicle1CapaScore]
,t2.[Vehicle2Score]
+ case when t3.[Vehicle2Score] is null then 0 else t3.[Vehicle2Score] end
+ case when t4.[Vehicle2Score] is null then 0 else t4.[Vehicle2Score] end as [Vehicle2CapaScore]
,t2.[Vehicle3Score]
+ case when t3.[Vehicle3Score] is null then 0 else t3.[Vehicle3Score] end
+ case when t4.[Vehicle3Score] is null then 0 else t4.[Vehicle3Score] end as [Vehicle3CapaScore]
from Table1 as t1 left outer join
Table2 as t2 on
t1.Capability.1 = t2.[Capability] left outer join
Table2 as t3 on
t1.Capability.2 = t3.[Capability] left outer join
Table2 as t4 on
t1.Capability.3 = t4.[Capability] left outer join