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
mramstead1
Frequent Visitor

M Code Load Issue with a Duplicated Query

Hello all,

 

I have a 30,000 row query that tracks the activities completed by our service team. One of the things we are trying to track is how many activities are completed for individual clients. The problem is we have multiple names for some clients that share the same client code which messed up aggregation of data on the visual side.

 

In order to clean it up, I duplicated the 30,000 row query, only kept client code and client name columns, removed duplicate client codes (to create a mapping table) and then disabled this query from loading into the model. This mapping table causes little to no strain on the model loading time.

 

This is the code for the main data table before I added the name transformation:

mramstead1_0-1649351857603.png

This data (along with my date table and two small mapping tables) takes about 1 minute to load into the visualizations (50 mb). 

 

Here is the added code in order to get all of the client names to be the same (Same code as above with additional steps):

mramstead1_1-1649352183598.png

This stops the model from loading completely (Goes up into the gigabytes of loaded data taking hours. I am guessing this has to do with the table referencing but I am not sure why it is breaking. I am still learning Power BI/Query and by no means have best practices down.

 

Here's my query dependencies (in case that is important):

mramstead1_2-1649352341061.png

 

If there is a better bit of code to use in order to get the same result or if I need to do something altogether, I would love some feedback!

 

Thank you in advance for the help!

1 ACCEPTED SOLUTION
watkinnc
Super User
Super User

If what you are trying to do is have a table of unique LookupCodes that relates to the fact table LookUp codes, and want to display a Client name from the Dimension table, couldn't you make a new query with just the two columns, like:

 

= Table.Distinct(FactTable[[LookupCode], [Client]], "LookupCode")

 

And then just set the relationship with LookupCode on the one side, and the LookupCode column in the fact table as the many side?

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

View solution in original post

2 REPLIES 2
watkinnc
Super User
Super User

If what you are trying to do is have a table of unique LookupCodes that relates to the fact table LookUp codes, and want to display a Client name from the Dimension table, couldn't you make a new query with just the two columns, like:

 

= Table.Distinct(FactTable[[LookupCode], [Client]], "LookupCode")

 

And then just set the relationship with LookupCode on the one side, and the LookupCode column in the fact table as the many side?

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

Thanks for replying Nate! That is an option that should work, I was just concerned on the memory issues that might occur loading another query into the model. The client list is under 5,000 at the moment, but that could grow significantly throughout the year (the data starts at 1/1/22 and compounds throughout the year).

 

I have a similar bit of M Code in another query that gets appended into the main Activity query, so I thought I would be able to achieve something similar with client names. Here's a picture of the code from the query with the working code:

mramstead1_0-1649362870372.png

 

If this is an inefficient way to model I will more than happily use the code you listed above, I'm just trying to understand why the CSR24 query code works and the other code loads eternally, most likely due to a circular reference that I overlooked.

 

Either way I look forward to hearing your thoughts on this.

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.

Top Solution Authors