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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
vassdavid
Frequent Visitor

Apply rules on a table in Power Query

Hi All!

 

I'd like to apply rules on a Power BI dataset. Is this possible?

 

Example:

1. table is the 'Logic file' (Excel) where the rules are stored:

Company codeReportName of the column serving the basis of data change that need to be done #1 Data that should be changed #1Name of the column serving the basis of data change that need to be done #2Data that should be changed #2Name of the column serving the basis of data change that need to be done #3Data that should be changed #3Name of the column(s) in which the data need to be changedChange to
XX01ArrivalsDescriptionNaphta    Commodity code11
ZZ02ArrivalsCommodity Code(blank)IR Amount(LC)>0IR Amount(LC)≤500Commodity Code104
XX01DispatchMode of Trans.<1    Mode of Trans.3
XX01DispatchMode of Trans.>8    Mode of Trans.3
YY01ArrivalsMaterial Ctry Orig(blank)    Material Ctry Orig=Orig.country
YY01ArrivalsMaterial Ctry OrigYY    Material Ctry Orig=Orig.country

 

2. table is the report (multiple Excel files appended in Power Query) where the rules need to be applied:

ReportCommodity CodeCompany CodeDescriptionMode of Trans.IR Amount(LC)Material Ctry OrigOrig.country
Arrivals1234567XX01dummy71,000,000.00  
Arrivals1234567XX01dummy72,000.00  
Dispatch1234567ZZ02dummy71,000,000.00  
Arrivals1234567XX01Naphta71,000,000.00  
Arrivals ZZ02dummy7100.00  
Arrivals1234567YY01dummy7600.00 Belgium
Arrivals1234567YY01dummy7500.00YYBelgium

 

Expected result:

ReportCommodity CodeCompany CodeDescriptionMode of Trans.IR Amount(LC)Material Ctry OrigOrig.country
Arrivals1234567XX01dummy71,000,000.00  
Arrivals1234567XX01dummy72,000.00  
Dispatch1234567ZZ02dummy71,000,000.00  
Arrivals11XX01Naphta71,000,000.00  
Arrivals104ZZ02dummy7100.00  
Arrivals1234567YY01dummy7600.00BelgiumBelgium
Arrivals1234567YY01dummy7500.00BelgiumBelgium

 

Maybe it'd be easier to achieve this by writing a macro in Excel, but I only would like to do that if there's no other way.

 

Any suggestions would be greatly appreciated.

 

Thank you in advance!

 

David

2 REPLIES 2
parry2k
Super User
Super User

@vassdavid I don;t think you can read rules from a file and apply it, you can surely manually add the steps in power query for each rule.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2kThanks for the quick reply. I will consider the manual solution, but I'm afraid that won't be the best in this case. We're still collecting, but we're going to have around 500 rules I'd say.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.