Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Data Source Change - M Script

Hi Experts

 

I am trying to change my data source from Server A to Server B that table names are the same in the two servers.  What i want to do is update the old tables currently in Power BI with the new data from Server B. I want to keep the existing applied steps that where applied to the old data set, but refresh that with the new data from Server B.

 

Keep Server A data refresh with Server B Data..

Server A M -Script Code

let
    Source = Oracle.Database("ABC-ABD/hsfsdhfos", [Query="SELECT#(lf)#(tab)primarynjrindexno,#(lf)#(tab)primaryprocedureid,#(lf)#(tab)primarysurgicalunitid,#(lf)#(tab)primaryconsultant,#(lf)#(tab)primarylead,#(lf)#(tab)joint,#(lf)#(tab)side,#(lf)#(tab)patientgender,#(lf)#(tab)ageatprimary,#(lf)#(tab)primarybmi,#(lf)#(tab)primaryasa,#(lf)#(tab)primaryopdate,#(lf)#(tab)outcometype,#(lf)#(tab)primarytooutcomeyears,#(lf)#(tab)ageatdeath,#(lf)#(tab)lastpatienttracedate,#(lf)#(tab)revisiondate,#(lf)#(tab)cupfixation,#(lf)#(tab)headfixation,#(lf)#(tab)stemfixation,#(lf)#(tab)indrev_summaryrevisionreasons,#(lf)#(tab)stembrand,#(lf)#(tab)cupbrand,#(lf)#(tab)linercatno,#(lf)#(tab)headbrand,#(lf)#(tab)headcatno,#(lf)#(tab)stemcatno,#(lf)#(tab)cupcatno,#(lf)#(tab)revisioncupcatno,#(lf)#(tab)revisionlinercatno,#(lf)#(tab)revisionheadcatno,#(lf)#(tab)cemented_stem_removed,#(lf)    stem_cement_removed,#(lf)    cemented_cup_removed,#(lf)    cup_cement_removed,#(lf)    uncemented_stem_removed,#(lf)    uncemented_cup_removed,#(lf)    ncmntd_cp_lnr_nly_rmvd,#(lf)    femoral_head_removed,#(lf)    femoral_stem_removed,#(lf)    femoral_stem_removed_brand,#(lf)    fmrl_stm_rmvd_brnd_nvlbl,#(lf)    acetabular_cup_removed,#(lf)    acetabular_cup_removed_brand,#(lf)    ctblr_cp_rmvd_brnd_nvlbl,#(lf)    componentsremovedsummary,#(lf)    file_nm,#(lf)    file_name_dt#(lf)#(tab)#(lf)/*  revisiondb,#(lf)    primarydb,#(lf)    leadsurgeongrade,#(lf)    primaryproceduretype,#(lf)    primarypatientprocedure,#(lf)    approach,#(lf)    minimallyinvasivetechnique,#(lf)    computerguidedsurgery,#(lf)    indforimp_osteoarthritis,#(lf)    indforimp_avascularnecrosis,#(lf)    ndfrmp_thrnflmmtryrthrpthy,#(lf)    ndfrmp_cttrmnckffmr,#(lf)    indforimp_chronictrauma,#(lf)    ndfrmp_prvssrgrynntrmrltd,#(lf)    ndfrmp_nkylsngspndylts,#(lf)    ndfrmp_cngntldslctdysplsfhp,#(lf)    ndfrmp_fldhmrthrplsty,#(lf)    ndfrmp_fldntrnlfxtn,#(lf)    indforimp_fracturedacetabulum,#(lf)    indforimp_fracturedneckoffemur,#(lf)    indforimp_otherhiptrauma,#(lf)    indforimp_perthes,#(lf)    indforimp_previousarthrodesis,#(lf)    indforimp_psoriaticarthropathy,#(lf)    ndfrmp_srpstvrhmtdrthrts,#(lf)    ndfrmp_srngtvrhmtdrthrts,#(lf)    ndfrmp_slppdpprfmrlpphyss,#(lf)    indforimp_previousinfection,#(lf)    indforimp_trauma,#(lf)    ndfrmp_prvshptrmntspcfd,#(lf)    indforimp_indicationother,#(lf)    indforimp_sufe,#(lf)    ndfrmp_mtsttccncrrmlgnncy,#(lf)    indforimp_skeletaldysplasia,#(lf)    indforimp_othertext,#(lf)    indforimp_summary,#(lf)    thromboc_aspirin,#(lf)    thromboc_lmwh,#(lf)    thromboc_pentasaccharide,#(lf)    thromboc_warfarin,#(lf)    thrmbc_drctthrmbnnhbtr,#(lf)    thromboc_factorxainhibitor,#(lf)    thromboc_other,#(lf)    thromboc_none,#(lf)    thrombom_footpump,#(lf    thrombom_ted,#(lf)    thrombom_calfcompression,#(lf)    thrombom_other,#(lf)    thrombom_none,#(lf)    adverseevent_none,#(lf)    adverseevent_calcarcrack,#(lf)    adverseevent_pelvicpenetration,#(lf)    adverseevent_shaftfracture,#(lf)    adverseevent_shaftpenetration,#(lf)    dvrsvnt_trchntrcfrctr,#(lf)    adverseevent_other,#(lf)    adverseevent_summary,#(lf)    bonegraftfemur,#(lf)    bonegraftacetabular,#(lf)    cuparticulation,#(lf)    headarticulation,#(lf)    cupmanufacturer,#(lf)    cupdistributer,#(lf)    cupparentmanufacturer,#(lf)    cupgroup,#(lf)    cuptype,#(lf)    cupcomposition,#(lf)    cupcompositionform,#(lf)    cupsize,#(lf)    cupodeprating,#(lf)    cupdetails,#(lf)    cupbatchno,#(lf)    cupimplanttype,#(lf)    linermanufacturer,#(lf)    linerdistributer,#(lf)    linerparentmanufacturer,#(lf)    linergroup,#(lf)    linertype,#(lf)    linercomposition,#(lf)    linercompositionform,#(lf)    linersize,#(lf)    linerdetails,#(lf)    linerbatchno,#(lf)    linerimplanttype,#(lf)    headmanufacturer,#(lf)    headdistributer,#(lf)    headparentmanufacturer,#(lf)    headgroup,#(lf)    headtype,#(lf)    headcomposition,#(lf)    headcompositionform,#(lf)    headsize,#(lf)    headodeprating,#(lf)    headdetails,#(lf)    headbatchno,#(lf)    headimplanttype,#(lf)    stemmanufacturer,#(lf)    stemdistributer,#(lf)    stemgroup,#(lf)    stemtype,#(lf)    stemsize,#(lf)    stemodeprating,#(lf)    stemdetails,#(lf)    stembatchno,#(lf)    stemimplanttype,#(lf)    stemproximalmanufacturer,#(lf)    stemproximaldistributer,#(lf)    stemproximalbrand,#(lf)    stemproximalgroup,#(lf)    stemproximaltype,#(lf)    stemproximalfixation,#(lf)    stemproximalodeprating,#(lf)    stemproximalcatno,#(lf)    stemproximaldetails,#(lf)    stemproximalbatchno,#(lf)    stemproximalimplanttype,#(lf)    stemdistalmanufacturer,#(lf)    stemdistaldistributer,#(lf)    stemdistalgroup,#(lf)    stemdistaltype,#(lf)    stemdistalfixation,#(lf)    stemdistalcatno,#(lf)    stemdistaldetails,#(lf)    stemdistalbatchno,#(lf)    stemdistalimplanttype,#(lf)    cementmanufacturer01,#(lf)    cementdistributer01,#(lf)    cementbrand01,#(lf)    cementgroup01,#(lf)    cementtype01,#(lf)    cementcatno01,#(lf)    cementdetails01,#(lf)    cementbatchno01,#(lf)    cementimplanttype01,#(lf)    cementmanufacturer02,#(lf)    cementdistributer02,#(lf)    cementbrand02,#(lf)    cementgroup02,#(lf)    cementtype02,#(lf)    cementcatno02,#(lf)    cementdetails02,#(lf)    cementbatchno02,#(lf)    cementimplanttype02,#(lf)    stemcentralizermanufacturer,#(lf)    stemcentralizerdistributer,#(lf)    stemcentralizertype,#(lf)    stemcentralizercatno,#(lf)    stemcentralizerdetails,#(lf)    stemcentralizerbatchno,#(lf)    stemcentralizerimplanttype,#(lf)    stemcentralsectionmanufacturer,#(lf)    stemcentralsectiondistributer,#(lf)    stemcentralsectiontype,#(lf)    stemcentralsectioncatno,#(lf)    stemcentralsectiondetails,#(lf)    stemcentralsectionbatchno,#(lf)    stemcentralsectionimplanttype,#(lf)    femoralcanalplugmanufacturer,#(lf)    femoralcanalplugdistributer,#(lf)    femoralcanalplugtype,#(lf)    femoralcanalplugcatno,#(lf)    femoralcanalplugdetails,#(lf)    femoralcanalplugbatchno,#(lf)    femoralcanalplugimplanttype,#(lf)    taperadaptermanufacturer,#(lf)    taperadapterdistributer,#(lf)    taperadaptertype,#(lf)    taperadaptercatno,#(lf)    taperadapterdetails,#(lf)    taperadapterbatchno,#(lf)    taperadapterimplanttype,#(lf)    revisionnjrindexno,#(lf)    revisionprocedureid,#(lf)    revisionproceduretype,#(lf)    revisionpatientprocedure,#(lf)    revisionsurgicalunitid,#(lf)    revisionconsultant,#(lf)    revisionleadsurgeon,#(lf)    indrev_asepticlooseningstem,#(lf)    indrev_asepticlooseningsocket,#(lf)    indrev_mds1asepticloosening,#(lf)    indrev_dislocationsubluxation,#(lf)    indrev_implantfracturestem,#(lf)    indrev_implantfracturesocket,#(lf)    indrev_implantfracturehead,#(lf)    indrev_incorrectsizingsocket,#(lf)    indrev_incorrectsizinghead,#(lf)    indrev_incorrectsizing,#(lf)    indrev_mds1incorrectsizing,#(lf)    indrev_infection,#(lf)    indrev_lysisstem,#(lf)    indrev_lysissocket,#(lf)    indrev_mds1lysis,#(lf)    indrev_malalignmentstem,#(lf)    indrev_malalignmentsocket,#(lf)    indrev_malalignment,#(lf)    indrev_pain,#(lf)    ndrv_prprsthtcfrctrstm,#(lf)    ndrv_prprsthtcfrctrsckt,#(lf)    indrev_periprostheticfracture,#(lf)    ndrv_wrfctblrcmpnnt,#(lf)    ndrv_wrfplythylncmpnnt,#(lf)    indrev_dissociationofliner,#(lf)    ndrv_dvrssfttssrctntprtcldbrs,#(lf)    indrev_other,#(lf)    indrev_othertext,#(lf)    revisioncupmanufacturer,#(lf)    revisioncupparentmanufacturer,#(lf)    revisioncupbrand,#(lf)    revisioncupdetails,#(lf)    revisionlinermanufacturer,#(lf)    rvsnlnrprntmnfctrr,#(lf)    revisionlinerdetails,#(lf)    revisionheadmanufacturer,#(lf)    revisionheadparentmanufacturer,#(lf)    revisionheadbrand,#(lf)    revisionheaddetails,#(lf)    revisionstemmanufacturer,#(lf)    revisionstembrand,#(lf)    revisionstemcatno,#(lf)    revisionstemdetails,#(lf)    rvsnstmprxmlmnfctrr,#(lf)    revisionstemproximalbrand,#(lf)    revisionstemproximalcatno,#(lf)    revisionstemproximaldetails,#(lf)    revisionstemdistalmanufacturer,#(lf)    revisionstemdistalcatno,#(lf)    revisionstemdistaldetails,#(lf)    rvsnstmcntrlzrlmnfctrr,#(lf)    revisionstemcentralizerdetails,#(lf)    rvsnstmcntrlsctnmnfctrr,#(lf)    rvsnstmcntrlsctndtls,#(lf)    rvsnfmrlcnlplgmnfctrr,#(lf)    rvsnfmrlcnlplgdtls,#(lf)    revisioncementmanufacturer01,#(lf)    revisioncementbrand01,#(lf)    revisioncementdetails01,#(lf)    revisioncementmanufacturer02,#(lf)    revisioncementbrand02,#(lf)    revisioncementdetails02 */#(lf)FROM#(lf)    njrew_h_prmry_outcm", CreateNavigationProperties=false]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"PRIMARYNJRINDEXNO", Int64.Type}, {"AGEATPRIMARY", Int64.Type}, {"PRIMARYBMI", Int64.Type}, {"PRIMARYTOOUTCOMEYEARS", type number}, {"AGEATDEATH", type number}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type",null,"NA",Replacer.ReplaceValue,{"CUPBRAND"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","na","NA",Replacer.ReplaceText,{"CUPBRAND"}),
    #"Filtered Rows" = Table.SelectRows(#"Replaced Value1", each true),
    #"Replaced Value2" = Table.ReplaceValue(#"Filtered Rows",null,"NA",Replacer.ReplaceValue,{"HEADBRAND"}),
    #"Filtered Rows1" = Table.SelectRows(#"Replaced Value2", each true),
    #"Replaced Value3" = Table.ReplaceValue(#"Filtered Rows1",null,"NA",Replacer.ReplaceValue,{"STEMBRAND"}),
    #"Replaced Value4" = Table.ReplaceValue(#"Replaced Value3","na","NA",Replacer.ReplaceText,{"STEMBRAND"}),
    #"Filtered Rows2" = Table.SelectRows(#"Replaced Value4", each true),
    #"Replaced Value5" = Table.ReplaceValue(#"Filtered Rows2",null,"NA",Replacer.ReplaceValue,{"CUPFIXATION"}),
    #"Replaced Value6" = Table.ReplaceValue(#"Replaced Value5","na","NA",Replacer.ReplaceText,{"CUPFIXATION"}),
    #"Filtered Rows3" = Table.SelectRows(#"Replaced Value6", each true),
    #"Replaced Value7" = Table.ReplaceValue(#"Filtered Rows3",null,"NA",Replacer.ReplaceValue,{"HEADFIXATION"}),
    #"Filtered Rows4" = Table.SelectRows(#"Replaced Value7", each true),
    #"Replaced Value8" = Table.ReplaceValue(#"Filtered Rows4",null,"NA",Replacer.ReplaceValue,{"STEMFIXATION"}),
    #"Replaced Value9" = Table.ReplaceValue(#"Replaced Value8","na","NA",Replacer.ReplaceText,{"STEMFIXATION"}),
    #"Filtered Rows5" = Table.SelectRows(#"Replaced Value9", each true),
    #"Replaced Value10" = Table.ReplaceValue(#"Filtered Rows5",null,"NA",Replacer.ReplaceValue,{"CUPCATNO"}),
    #"Filtered Rows6" = Table.SelectRows(#"Replaced Value10", each true),
    #"Replaced Value11" = Table.ReplaceValue(#"Filtered Rows6",null,"NA",Replacer.ReplaceValue,{"HEADCATNO"}),
    #"Filtered Rows7" = Table.SelectRows(#"Replaced Value11", each true),
    #"Replaced Value12" = Table.ReplaceValue(#"Filtered Rows7",null,"NA",Replacer.ReplaceValue,{"STEMCATNO"}),
    #"Replaced Value13" = Table.ReplaceValue(#"Replaced Value12","na","NA",Replacer.ReplaceText,{"STEMCATNO"}),
    #"Filtered Rows8" = Table.SelectRows(#"Replaced Value13", each true),
    #"Replaced Value14" = Table.ReplaceValue(#"Filtered Rows8",null,"NA",Replacer.ReplaceValue,{"LINERCATNO"}),
    #"Replaced Value15" = Table.ReplaceValue(#"Replaced Value14","na","NA",Replacer.ReplaceText,{"LINERCATNO"}),
    #"Filtered Rows9" = Table.SelectRows(#"Replaced Value15", each true),
    #"Replaced Value16" = Table.ReplaceValue(#"Filtered Rows9",null,"NA",Replacer.ReplaceValue,{"REVISIONCUPCATNO"}),
    #"Replaced Value17" = Table.ReplaceValue(#"Replaced Value16","na","NA",Replacer.ReplaceText,{"REVISIONCUPCATNO"}),
    #"Filtered Rows10" = Table.SelectRows(#"Replaced Value17", each true),
    #"Replaced Value18" = Table.ReplaceValue(#"Filtered Rows10",null,"NA",Replacer.ReplaceValue,{"REVISIONHEADCATNO"}),
    #"Filtered Rows11" = Table.SelectRows(#"Replaced Value18", each true),
    #"Replaced Value19" = Table.ReplaceValue(#"Filtered Rows11",null,"NA",Replacer.ReplaceValue,{"REVISIONLINERCATNO"}),
    #"Replaced Value20" = Table.ReplaceValue(#"Replaced Value19","na","NA",Replacer.ReplaceText,{"REVISIONLINERCATNO"}),
    #"Filtered Rows12" = Table.SelectRows(#"Replaced Value20", each true)
in
    #"Filtered Rows12"

Server B M Script Code

let
    Source = Oracle.Database("Bkah-Bkah", [HierarchicalNavigation=true]),
    USER_PMPA = Source{[Schema="USER_PMPA"]}[Data],
    NJREW_H_PRMRY_OUTCM1 = USER_PMPA{[Name="NJREW_H_PRMRY_OUTCM"]}[Data]
in
    NJREW_H_PRMRY_OUTCM1
1 ACCEPTED SOLUTION
vanessafvg
Community Champion
Community Champion

@Anonymous  can you explain what your purpose is?

any server you point to fulll replace the data, so it sounds to me like you looking for an incremental load from b after you have loaded all the data from a?

 

what you probably need to do is create both sources and then merge them if you want to retain the data from both sides, unless you have premuim and use the power bi service, i have never tried it but you potentially could fulll load from a and then incrementally load from b using the service





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
vanessafvg
Community Champion
Community Champion

@Anonymous  can you explain what your purpose is?

any server you point to fulll replace the data, so it sounds to me like you looking for an incremental load from b after you have loaded all the data from a?

 

what you probably need to do is create both sources and then merge them if you want to retain the data from both sides, unless you have premuim and use the power bi service, i have never tried it but you potentially could fulll load from a and then incrementally load from b using the service





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Anonymous
Not applicable

Hi Experts

 

That is what i am trying to do, i have premium, but the views (oracle from A do not exits anymore) hence why i am trying to replace the old data with the new data from Server B.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.