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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Data type issue when applying a relationship

My data types have been set in Power Query for the fields Base 93 Price, Count and Each Price in the "codes" table and show the Sigma sign. 

dpeacock_0-1593035110828.png

Once I apply the relationship to the "Sales" table (Material to Item# as a one (material) to many (item#), this happens:

dpeacock_1-1593035234676.png

It pulls the data correctly, but the fields in the "codes" table are not showing the "sigma"  - even thought they're coded as whole numbers or currency and I can't use them in a calculated column or get a total of the Count field (count is the "eaches" in a pack of the product - so either a dozen, 2 dozen or 3 dozen).

dpeacock_2-1593035310273.png

Can someone let me know what I'm doing wrong because my head hurts trying to figure this out.

Thanks much!

 

 

1 ACCEPTED SOLUTION

Hi @PaulDBrown ,

 

Like everything else in Power BI, there are no absolutes, but a few things about key fields vs value fields:

  1. Key fields should be unique on the 1 side. I'm ignoring the complexities of the many to many relationships.
  2. Key fields should generally be hidden on the many side. I've seen a lot of problems in reports where the key field was used in a visual in a FACT table vs the DIM table. Doing this with dates will prevent time intelligence functions from working.
  3. As noted by the OP, the sigma sign is vanishing, and while that appears on the face of it to be a visual issue, I don't know what SSAS is doing underneath when that field is used as a filter relationship.
  4. While I am sure someone will come up with a scenario, what possible mathematical use would a unique value have in a table besides counting? If you are just counting, you can count the rows. But you shouldn't be dropping that field into a visual to create an implicit measure, not from the FACT or DIM table. You could drop it in a table as a column or matrix as column/row as you would a part number, but not in values. 
  5. Unless it is a unique ID generated by SQL or other database, I almost always convert numeric IDs to text before using them with filter relationships. It ensures they don't break if any alpha chars get introduced. Part numbers, employee numbers, etc.

 

I would just recommend creating a duplicate column in Power Query, then using that. Your "many" key field should be hidden anyway, so wouldn't cause confusion. 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

9 REPLIES 9
edhans
Super User
Super User

If the sigma is not showing up, then they are either coming in as "ANY" from Power Query, which is when the field has ABC/123 as the data type (always a bad idea), or they are formatted as text.

 

Formatting data in DAX by clicking on it is formatting only and will not change the data type. Power Query can change the type, which is what you need to do.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

I have the data type set in Power Query:

dpeacock_0-1593037356522.png

What's happening is that once I apply the relationship, the Sigma goes away.  If I delete the relationship, it comes back.

It is just a visual thing, and I'm not sure why. I set to tables up with integers and the sigma was there. I then joined as a 1:Many relationship and the sigma's vanished, but I was still able to summarize, add calculated columns, and create measures on those columns.

 

That said, your key fields in relationships should not be used in calculations. Create a duplicate column in Power Query and use those for calcs.

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting


@edhans wrote:

"your key fields in relationships should not be used in calculations. Create a duplicate column in Power Query and use those for calcs."


@edhans 
I wasn't aware of a potential problem with using key fields in calculations. What are the risks? (I'm trying to think of examples of when I would use a key field in a calc, but I am only coming up with using them in FILTER expressions....). But just in case...

Thanks!

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Hi @PaulDBrown ,

 

Like everything else in Power BI, there are no absolutes, but a few things about key fields vs value fields:

  1. Key fields should be unique on the 1 side. I'm ignoring the complexities of the many to many relationships.
  2. Key fields should generally be hidden on the many side. I've seen a lot of problems in reports where the key field was used in a visual in a FACT table vs the DIM table. Doing this with dates will prevent time intelligence functions from working.
  3. As noted by the OP, the sigma sign is vanishing, and while that appears on the face of it to be a visual issue, I don't know what SSAS is doing underneath when that field is used as a filter relationship.
  4. While I am sure someone will come up with a scenario, what possible mathematical use would a unique value have in a table besides counting? If you are just counting, you can count the rows. But you shouldn't be dropping that field into a visual to create an implicit measure, not from the FACT or DIM table. You could drop it in a table as a column or matrix as column/row as you would a part number, but not in values. 
  5. Unless it is a unique ID generated by SQL or other database, I almost always convert numeric IDs to text before using them with filter relationships. It ensures they don't break if any alpha chars get introduced. Part numbers, employee numbers, etc.

 

I would just recommend creating a duplicate column in Power Query, then using that. Your "many" key field should be hidden anyway, so wouldn't cause confusion. 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

@edhans 

 

Thanks for that very comprehensive explanation. It all makes sense of course.
I particularly like your "best practice" of converting Numeric IDs to text. 

Again, thank you for taking the time to offer the explanation. Much appreciated!

 

Best,

Paul.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

I'll dive back into it but it wasn't letting me do a calculated column using the "count" field.  Thanks for the feedback!

Ok. Let us know how it goes. Mark my answer as Solved if this is the solution so others can find this, or post back with other info.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

I changed the name from Count to ItemCt and it let me do the calculation even though the Sigma wasn't there. So you were right with respect to that just being a visual thing - WHICH THEY SHOULD FIX - but on top of that I needed to change the name of the field. I really should have not named it that - no need for that kind of confusion!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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