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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Jeffery24
Helper I
Helper I

Add functions based on parameter - M coding

Hi,

 

I would like to merge a table in power query only if a parameter is met, if not it doesnt load.

Something like;

If LeadTimeCriteria = "Contracted" then
// Add contracted table and columns

AddContractedTimes = Table.NestedJoin(LeadTimeEventPlannedB,{"POL", "POD", "Transport Mode", "Carrier"},#"Contracted Transits",{"POL", "POD", "Load Type", "Carrier"},"Contracted Transits",JoinKind.LeftOuter), SetupContractedTransits = Table.ExpandTableColumn(AddContractedTimes, "Contracted Transits", {"Carrier Choice", "Transit Time port - port (Days)", "Valid From", "Valid To"}, {"Contracted Transits.Carrier Choice", "Contracted Transits.Transit Time port - port (Days)", "Contracted Transits.Valid From", "Contracted Transits.Valid To"}), AdjustColumns = Table.RenameColumns(SetupContractedTransits,{{"Contracted Transits.Carrier Choice", "Lead Time Contracted Carrier Choice"}, {"Contracted Transits.Transit Time port - port (Days)", "Lead Time Contracted P2P Transit Time"}, {"Contracted Transits.Valid From", "Lead Time Contracted Valid From"}, {"Contracted Transits.Valid To", "Lead Time Contracted Valid To"}}),

Else

// do nothing

Is it possible to use the if function in this way similar in VBA?

Thanks in advance

1 ACCEPTED SOLUTION
TeigeGao
Solution Sage
Solution Sage

Hi @Jeffery24 ,

Power Query if function can only handle data rather than the control process. As a result, we cannot use it in your scenario.

Best Regards,

Teige

View solution in original post

2 REPLIES 2
TeigeGao
Solution Sage
Solution Sage

Hi @Jeffery24 ,

Power Query if function can only handle data rather than the control process. As a result, we cannot use it in your scenario.

Best Regards,

Teige

Hi Teige,

 

Many thanks for your reply. I thought that might be the case I just wanted to check. Smiley Happy

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.