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
rhborders
Helper I
Helper I

Creating groups based on numbers

I would like to be able to create a column that calculates the average date that an invoice is created. I need this average to be filtered based on both product ID as well as customer ID. I was able to create a working calculated table in Visual Studio that looks like this: =GROUPBY(Fact_Invoice_Line,Fact_Invoice_Line[Customer_ID],Fact_Invoice_Line[Product_ID],"Invoice Means",(Fact_Invoice_LineAVERAGEX(CURRENTGROUP(),Fact_Invoice_Line[Invoice_Date_ID]))) . The issue that I ran into with this is that I need to create a key to connect this calculated table that does the same thing, but instead of finding the average it finds the standard devation. I tried to concatinate the product ID and customer ID but I have repeating values of -1 that are not needed and create duplicates. What I am trying to work out is a way to remove the -1 from Product ID and Customer ID or filter them out so that I can create a relationship to be able to put both of them in a Power BI data set. If someone knows how to directly do this work in Power BI that would work as well. The reason I created it in Visual Studio is because Power BI wouldn't accept my GROUPBY function.

1 ACCEPTED SOLUTION

@rhborders,

Did you remove the duplicates in your bridge table??

If not, then remove it. 

 

Also it doesn't matter how many every repeating values you have in your table. Since you are going to remove the duplicates from your bridge table, your bridge table will act as a unique key for joining the tables

View solution in original post

3 REPLIES 3
Thejeswar
Resident Rockstar
Resident Rockstar

Hi @rhborders,

Between your Fact Table in Power BI and the New Calculated table, introduce a new bridge table that will have only one column. This column will be the concatenation of CustomerID and ProductID.

 

Now join your fact table and Calculated table through this bridge table

 

Note: Your fact table and Calculated table also will have the concatenated column. Only then you can connect the tables

Something similar to the image given below

 

 

relationship.PNG

 

Hey @Thejeswar,

 

I tried to do this and ran into the problem of having repeat values so it couldn't be a unique key. In both my customer ID and Product ID I have -1 representing when our company makes a sale versus one of our sales reps making a sale. This results in the multiple values that repeat. I had tried to write out a function that filtered out the -1 but couldn't find one that worked.

@rhborders,

Did you remove the duplicates in your bridge table??

If not, then remove it. 

 

Also it doesn't matter how many every repeating values you have in your table. Since you are going to remove the duplicates from your bridge table, your bridge table will act as a unique key for joining the tables

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.