Import union DAX statement into data model?

%3CLINGO-SUB%20id%3D%22lingo-sub-1098734%22%20slang%3D%22en-US%22%3EImport%20union%20DAX%20statement%20into%20data%20model%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1098734%22%20slang%3D%22en-US%22%3E%3CP%3EGood%20morning.%20So%20my%20first%20question%20was%20a%20silly%20one%2C%20but%20now%20that%20is%20working%20I%20need%20to%20extend%20it%20a%20bit.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EI%20was%20using%20a%20DAX%20table%20to%20construct%20a%20list%20of%20unique%20keys%20for%20linking%20things%20together.%26nbsp%3B%3CBR%20%2F%3EIt%20works%20great%2C%20and%20now%20I%20have%20another%20set%20of%20SKUs%20in%20a%20different%20column%20that%20I%20would%20like%20to%20add%20to%20the%20end%20of%20the%20table.%3CBR%20%2F%3E%3CBR%20%2F%3EWe're%20not%20talking%20massive%20tables%20here%20-%20in%20SQL%20I%20would%20just%20do%20a%20union%20statement%2C%20and%20it%20turns%20out%26nbsp%3B%20there%20is%20something%20similar%20in%20DAX!%26nbsp%3B%3CSPAN%3EHappy%20days!%20%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3EI%20looked%20up%20union%20statements%2C%20copied%20the%20first%20formula%20in%2C%20changed%20some%20col%20IDs%20and%20it%20worked%20first%20time.%20It%20references%20different%20cols%2C%20but%20the%20output%20is%20identical%20-%20same%20column%20headers%20etc.%3CBR%20%2F%3E%3CBR%20%2F%3EHowever%2C%20even%20though%20the%20table%20is%20perfect%20on%20screen%2C%20when%20I%20refresh%20the%20data%20model%20to%20import%20the%20updated%20table%20it%20fails.%20Is%20it%20something%20I%20did%20or%20a%20limitation%20of%20Excel%3F%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20error%20message%20is%3A%3CBR%20%2F%3E%3CSTRONG%3E%3CFONT%3E%22We%20couldn%E2%80%99t%20refresh%20the%20connection.%20Please%20go%20to%20existing%20connections%20and%20verify%20they%20connect%20to%20the%20file%20or%20server.%22%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EAs%20soon%20as%20I%20take%20the%20UNION%20out%20it%20works%20again.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EHere%20is%20the%20DAX%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CDIV%3E%3CSTRONG%3E%3CFONT%3EEVALUATE%20%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%3CFONT%3EUNION%20(%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%3CFONT%3ECALCULATETABLE(%3CBR%20%2F%3ESELECTCOLUMNS('Products%20-%20database'%2C%26nbsp%3B%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22Lookup%22%2C%20'Products%20-%20database'%5Bfirst%20lookup%5D%2C%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22SKU%22%2C%20'Products%20-%20database'%5Bdistributor_sku%5D%2C%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22Cost%20Price%22%2C'Products%20-%20database'%5Bcost%5D%2C%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22Counter%22%2Ccount('Products%20-%20database'%5Bfirst%20lookup%5D)%3CBR%20%2F%3E)%3CBR%20%2F%3E%2C'Products%20-%20database'%5Bfirst%20lookup%5D%20%26lt%3B%26gt%3B%22%22%3CBR%20%2F%3E%2C'Products%20-%20database'%5Bcost%5D%20%26gt%3B0%3CBR%20%2F%3E)%20%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%3CFONT%3E%2C%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%3CFONT%3ECALCULATETABLE(%3CBR%20%2F%3ESELECTCOLUMNS('Products%20-%20database'%2C%26nbsp%3B%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22Lookup%22%2C%20'Products%20-%20database'%5Bsecond%20lookup%5D%2C%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22SKU%22%2C%20'Products%20-%20database'%5Bdistributor_sku%5D%2C%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22Cost%20Price%22%2C'Products%20-%20database'%5Bcost%5D%2C%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22Counter%22%2Ccount('Products%20-%20database'%5Bsecond%20lookup%5D)%3CBR%20%2F%3E)%3CBR%20%2F%3E%2C'Products%20-%20database'%5Bsecond%20lookup%5D%20%26lt%3B%26gt%3B%22%22%3CBR%20%2F%3E%2C'Products%20-%20database'%5Bcost%5D%20%26gt%3B0%3CBR%20%2F%3E)%20%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%3CFONT%3E)%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3CBR%20%2F%3ESteve%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EPS%3CBR%20%2F%3E%3CSPAN%3EI%20am%20u%3C%2FSPAN%3E%3CSPAN%3Esing%20externally%20provided%20data%2C%20so%20changing%20the%20input%20data%20isn't%20an%20option%20-%20I%20need%20to%20work%20with%20what%20they%20send%20me.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1098734%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1100838%22%20slang%3D%22en-US%22%3ERe%3A%20Import%20union%20DAX%20statement%20into%20data%20model%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1100838%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F511750%22%20target%3D%22_blank%22%3E%40lowndsy%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENot%20sure%20on%20your%20approach%20here.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHave%20you%20used%20Power%20Query%20to%20pull%20data%20into%20the%20data%20model%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1100917%22%20slang%3D%22en-US%22%3ERe%3A%20Import%20union%20DAX%20statement%20into%20data%20model%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1100917%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9832%22%20target%3D%22_blank%22%3E%40Wyn%20Hopkins%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EI%20don't%20think%20so%20-%20just%20Power%20Pivot%2C%20if%20that%20makes%20sense%3F%20I%20got%20the%20method%20I%20used%20from%20a%20recommendation%20on%20a%20blog%20somewhere%2C%20but%20if%20there%20is%20a%20better%20way%20I'll%20happily%20do%20that.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThe%20aim%20is%20just%20to%20get%20one%20perfect%20list%20of%20unique%20keys%20on%20one%20side%20of%20the%201%3A%20many%20relationship%20so%20I%20can%20enrich%20it%20with%20data%20from%20the%20csv%20data%2C%20which%20is%20full%20of%20blanks.%3CBR%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E1)%20Import%20csv%20files%20into%20Data%20model%20(legacy%20text%20wizard%2C%20connection%20only%2C%20prompt%20for%20file%20name%20on%20refresh)%3C%2FP%3E%3CP%3E2)%20Dump%20some%20columns%20back%20into%20the%20sheet%20as%20a%20table%20using%20a%20DAX%20query%20-%20with%20a%20few%20filters%3C%2FP%3E%3CP%3E3)%20Add%20that%20cleaned%20table%20back%20to%20the%20data%20model%20as%20a%20new%20source%20with%20%3CSTRONG%3Epower%20pivot%20%26gt%3B%20add%20to%20data%20model%3C%2FSTRONG%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CSPAN%3EThe%20csvs%20come%20from%20an%20external%20system%20and%20I%20want%20to%20avoid%20manually%20editing%20them.%3CBR%20%2F%3EI%20am%20basically%20building%20something%20where%20anyone%20in%20the%20office%20can%20click%20%22refresh%20all%22%2C%20select%20the%20latest%20files%20and%20go%20for%20a%20cup%20of%20tea%20while%20it%20crunches%20away.%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CBR%20%2F%3EI%20am%20happy%20enough%20with%20what%20I%20have%20so%20far%2C%20but%20it%20means%20I%20need%20there%20copies%20of%20the%20same%20system.%20Getting%20the%20UNION%20thing%20going%20(or%20equivalent)%20would%20be%20the%20icing%20on%20the%20cake%20and%20let%20me%20smush%20it%20all%20together%20into%20one%20file.%3CBR%20%2F%3EI%20would%20be%20a%20hero%20in%20the%20office.%20Gentlemen%20doff%20their%20caps%2C%20ladies%20would%20want%20to%20know%20me.%20Doors%20would%20open%20and%20Dogs%20would%20wag%20their%20tails%20at%20me.%20Or%20it%20could%20just%20save%20our%20us%20a%20load%20of%20pointless%20work%20every%20day%20-%20I'm%20easy.%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%2C%3CBR%20%2F%3ESteve%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1102549%22%20slang%3D%22en-US%22%3ERe%3A%20Import%20union%20DAX%20statement%20into%20data%20model%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1102549%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F511750%22%20target%3D%22_blank%22%3E%40lowndsy%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPerhaps%20I%20misunderstood%20your%20logic%20-%20tried%20to%20repeat%20on%20very%20simple%20model%20and%20UNION%20works.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHowever%2C%20from%20my%20point%20of%20view%20now%20that's%20a%20bit%20outdated%20technique.%20Such%20all%20transformations%20is%20more%20natural%20to%20do%20with%20Power%20Query.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1102575%22%20slang%3D%22en-US%22%3ERe%3A%20Import%20union%20DAX%20statement%20into%20data%20model%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1102575%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F511750%22%20target%3D%22_blank%22%3E%40lowndsy%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20are%20using%20Excel%202013%20or%20later%20then%20I'd%20strongly%20recommend%20a%20different%20approach%20and%20use%20Power%20Query%20to%20connect%20to%20your%20CSV%20files%2C%20clean%20the%20data%20up%20and%20load%20directly%20to%20Power%20Pivot.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20results%20in%20a%20fully%20automated%2C%20refreshable%20report%2C%26nbsp%3B%20and%20your%20goal%20of%20hero%20status%20will%20be%20fulfilled%20%3Arolling_on_the_floor_laughing%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20Power%20Query%20you%20can%20do%20all%20sorts%20of%20data%20manipulations%2C%20merges%2C%20appends%20etc%20to%20get%20your%20data%20into%20the%20right%20shape%20for%20the%20Data%20Model%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1100993%22%20slang%3D%22en-US%22%3ERe%3A%20Import%20union%20DAX%20statement%20into%20data%20model%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1100993%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9832%22%20target%3D%22_blank%22%3E%40Wyn%20Hopkins%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9832%22%20target%3D%22_blank%22%3E%40Wyn%20Hopkins%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EI%20don't%20think%20so%20-%20just%20Power%20Pivot.%20I%20got%20the%20method%20I%20used%20from%20a%20recommendation%20on%20a%20blog%20somewhere%2C%20but%20if%20there%20is%20a%20better%20way%20I'll%20happily%20do%20that.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThe%20aim%20is%20just%20to%20get%20one%20perfect%20list%20of%20unique%20keys%20on%20one%20side%20of%20the%201%3A%20many%20relationship%20so%20I%20can%20enrich%20and%20link%20the%20csv%20data.%3CBR%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E1)%20Import%20csv%20files%20into%20Data%20model%20(legacy%20text%20wizard%2C%20connection%20only%2C%20prompt%20for%20file%20name%20on%20refresh)%3C%2FP%3E%3CP%3E2)%20Dump%20some%20columns%20back%20into%20the%20sheet%20as%20a%20table%20using%20a%20DAX%20query%20-%20with%20a%20few%20filters%3C%2FP%3E%3CP%3E3)%20Add%20that%20cleaned%20table%20back%20to%20the%20data%20model%20as%20a%20new%20source%20with%20%3CSTRONG%3Epower%20pivot%20%26gt%3B%20add%20to%20data%20model%3C%2FSTRONG%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EStep%203%20Is%20where%20it%20fails%20-%20when%20I%20use%20a%20UNION%20to%20run%20the%20same%20query%20but%20on%20different%20columns%2C%20Excel%20gets%20upset%2C%20which%20is%20understandable%20because%20it%20is%20connecting%20to%20the%20same%20table%20twice.%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CSPAN%3EThe%20csv%20files%20come%20from%20an%20external%20system%20and%20I%20want%20to%20avoid%20manually%20editing%20them.%3CBR%20%2F%3EI%20am%20basically%20building%20something%20where%20anyone%20in%20the%20office%20can%20click%20%22refresh%20all%22%2C%20select%20the%20latest%20files%20and%20go%20for%20a%20cup%20of%20tea%20while%20it%20crunches%20away.%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CBR%20%2F%3EI%20am%20happy%20enough%20with%20what%20I%20have%20so%20far%2C%20but%20it%20means%20I%20need%20three%20copies%20of%20the%20same%20system.%20Getting%20the%20UNION%20thing%20going%20(or%20equivalent)%20would%20be%20the%20icing%20on%20the%20cake%20and%20let%20me%20smush%20it%20all%20together%20into%20one%20file.%3CBR%20%2F%3EI%20would%20be%20a%20hero%20in%20the%20office.%20Gentlemen%20doff%20their%20caps%2C%20ladies%20would%20want%20to%20know%20me.%20Doors%20would%20open%20and%20Dogs%20would%20wag%20their%20tails%20at%20me.%20Or%20it%20could%20just%20save%20our%20us%20a%20load%20of%20pointless%20work%20every%20day%20-%20I'm%20easy.%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%2C%3CBR%20%2F%3ESteve%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1104538%22%20slang%3D%22en-US%22%3ERe%3A%20Import%20union%20DAX%20statement%20into%20data%20model%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1104538%22%20slang%3D%22en-US%22%3E%3CP%3EThat%20makes%20sense.%20More%20than%20happy%20to%20jump%20over%20to%20Power%20Query%2C%20and%20I%20have%20even%20played%20around%20with%20it%20in%20the%20past%2C%20but%20I%20the%20thing%20that%20stopped%20me%20using%20it%20in%20anger%20was%20importing%20new%20files.%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20legacy%20text%20import%20has%20%22prompt%20for%20file%20name%20on%20refresh%22%2C%20so%20when%20the%20user%20clicks%20%22refresh%20all%22%20they%20see%20a%20browse%20window%20to%20specify%20which%20file(s)%20to%20import.%3CBR%20%2F%3ERenaming%20files%20and%20copying%20them%20into%20the%20same%20location%20isn't%20feasible%20for%20my%20users%20-%20I%20guarantee%20the%20people%20using%20it%20would%20mess%20it%20up%20within%20days%20and%20stop%20using%20it%20completely%20within%20a%20week.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20found%20other%20people%20asking%20about%20this%20feature%20and%20the%20answer%20seems%20to%20be%20no%3F%3CBR%20%2F%3E%3CFONT%3E%3CA%20href%3D%22https%3A%2F%2Fsuperuser.com%2Fquestions%2F1496004%2Fcan-power-query-prompt-for-a-file-name-when-loading-a-text-file%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fsuperuser.com%2Fquestions%2F1496004%2Fcan-power-query-prompt-for-a-file-name-when-loading-a-text-file%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EDoes%20anyone%20have%20a%20solution%3F%3C%2FFONT%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1106391%22%20slang%3D%22en-US%22%3ERe%3A%20Import%20union%20DAX%20statement%20into%20data%20model%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1106391%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20can't%20get%20it%20to%20prompt%20for%20a%20file%20name%20but%20you%20could%20allow%20users%20to%20enter%20the%20filename%20%2F%20path%20into%20a%20named%20cell%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Faccessanalytic.com.au%2Fpowerquery_namedcells_parameters%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Faccessanalytic.com.au%2Fpowerquery_namedcells_parameters%2F%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1106850%22%20slang%3D%22en-US%22%3ERe%3A%20Import%20union%20DAX%20statement%20into%20data%20model%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1106850%22%20slang%3D%22en-US%22%3E%3CP%3ESadly%20I'll%20have%20to%20stick%20to%20what%20I%20have%2C%20perhaps%20see%20if%20I%20can%20tweak%20the%20DAX%20statement%20to%20pull%20everything%20I%20need%20it%20to.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Good morning. So my first question was a silly one, but now that is working I need to extend it a bit. 

I was using a DAX table to construct a list of unique keys for linking things together. 
It works great, and now I have another set of SKUs in a different column that I would like to add to the end of the table.

We're not talking massive tables here - in SQL I would just do a union statement, and it turns out  there is something similar in DAX! Happy days!

I looked up union statements, copied the first formula in, changed some col IDs and it worked first time. It references different cols, but the output is identical - same column headers etc.

However, even though the table is perfect on screen, when I refresh the data model to import the updated table it fails. Is it something I did or a limitation of Excel? 

The error message is:
"We couldn’t refresh the connection. Please go to existing connections and verify they connect to the file or server."

 

As soon as I take the UNION out it works again.


Here is the DAX:

EVALUATE
UNION (
CALCULATETABLE(
SELECTCOLUMNS('Products - database',  
              "Lookup", 'Products - database'[first lookup],
              "SKU", 'Products - database'[distributor_sku],
              "Cost Price",'Products - database'[cost],
              "Counter",count('Products - database'[first lookup])
)
,'Products - database'[first lookup] <>""
,'Products - database'[cost] >0
)
,
CALCULATETABLE(
SELECTCOLUMNS('Products - database',  
              "Lookup", 'Products - database'[second lookup],
              "SKU", 'Products - database'[distributor_sku],
              "Cost Price",'Products - database'[cost],
              "Counter",count('Products - database'[second lookup])
)
,'Products - database'[second lookup] <>""
,'Products - database'[cost] >0
)
)

 

Thanks,
Steve

PS
I am using externally provided data, so changing the input data isn't an option - I need to work with what they send me.

 

8 Replies

Hi @lowndsy 

 

Not sure on your approach here. 

 

Have you used Power Query to pull data into the data model?

 

 

@Wyn Hopkins 


I don't think so - just Power Pivot, if that makes sense? I got the method I used from a recommendation on a blog somewhere, but if there is a better way I'll happily do that.

 

The aim is just to get one perfect list of unique keys on one side of the 1: many relationship so I can enrich it with data from the csv data, which is full of blanks.

1) Import csv files into Data model (legacy text wizard, connection only, prompt for file name on refresh)

2) Dump some columns back into the sheet as a table using a DAX query - with a few filters

3) Add that cleaned table back to the data model as a new source with power pivot > add to data model 

 

Step 3 Is where it fails - when I use a UNION to run the same query but on different columns, Excel gets upset, which is understandable because it is connecting to the same table twice. 


The csvs come from an external system and I want to avoid manually editing them.
I am basically building something where anyone in the office can click "refresh all", select the latest files and go for a cup of tea while it crunches away.


I am happy enough with what I have so far, but it means I need there copies of the same system. Getting the UNION thing going (or equivalent) would be the icing on the cake and let me smush it all together into one file.
I would be a hero in the office. Gentlemen doff their caps, ladies would want to know me. Doors would open and Dogs would wag their tails at me. Or it could just save our us a load of pointless work every day - I'm easy.

Thanks,
Steve

@Wyn Hopkins 

 

@Wyn Hopkins 


I don't think so - just Power Pivot. I got the method I used from a recommendation on a blog somewhere, but if there is a better way I'll happily do that.

 

The aim is just to get one perfect list of unique keys on one side of the 1: many relationship so I can enrich and link the csv data.

1) Import csv files into Data model (legacy text wizard, connection only, prompt for file name on refresh)

2) Dump some columns back into the sheet as a table using a DAX query - with a few filters

3) Add that cleaned table back to the data model as a new source with power pivot > add to data model 

 

Step 3 Is where it fails - when I use a UNION to run the same query but on different columns, Excel gets upset, which is understandable because it is connecting to the same table twice. 


The csv files come from an external system and I want to avoid manually editing them.
I am basically building something where anyone in the office can click "refresh all", select the latest files and go for a cup of tea while it crunches away.


I am happy enough with what I have so far, but it means I need three copies of the same system. Getting the UNION thing going (or equivalent) would be the icing on the cake and let me smush it all together into one file.
I would be a hero in the office. Gentlemen doff their caps, ladies would want to know me. Doors would open and Dogs would wag their tails at me. Or it could just save our us a load of pointless work every day - I'm easy.

Thanks,
Steve

@lowndsy 

Perhaps I misunderstood your logic - tried to repeat on very simple model and UNION works.

 

However, from my point of view now that's a bit outdated technique. Such all transformations is more natural to do with Power Query.

Hi @lowndsy 

 

If you are using Excel 2013 or later then I'd strongly recommend a different approach and use Power Query to connect to your CSV files, clean the data up and load directly to Power Pivot.

 

This results in a fully automated, refreshable report,  and your goal of hero status will be fulfilled

 

With Power Query you can do all sorts of data manipulations, merges, appends etc to get your data into the right shape for the Data Model

 

 

That makes sense. More than happy to jump over to Power Query, and I have even played around with it in the past, but I the thing that stopped me using it in anger was importing new files.

The legacy text import has "prompt for file name on refresh", so when the user clicks "refresh all" they see a browse window to specify which file(s) to import.
Renaming files and copying them into the same location isn't feasible for my users - I guarantee the people using it would mess it up within days and stop using it completely within a week.

 

I found other people asking about this feature and the answer seems to be no?
https://superuser.com/questions/1496004/can-power-query-prompt-for-a-file-name-when-loading-a-text-f...

Does anyone have a solution?

You can't get it to prompt for a file name but you could allow users to enter the filename / path into a named cell

 

https://accessanalytic.com.au/powerquery_namedcells_parameters/

 

 

Sadly I'll have to stick to what I have, perhaps see if I can tweak the DAX statement to pull everything I need it to.