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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
RYZGreg
New Member

Create Measures to Visualize Related Data across 3 relationships in snowflake schema

Having trialed with many errors on this for 3 weeks, I feel like I am lost in the woods and I've bitten off more than I can chew as a brand new user of Power BI. Hopefully someone much smarter than I can help me get over the finish line with a series of DAX measures to achieve my objective! 

 

Objective: Create a visualization that allows an account manager to filter their customer list by date to determine if their customers processed transactions in a previous month/year.

 

So far I have: A Slicer which filters a customer list by Account Manager and a Date Slicer. Where I am struggling is understanding how to connect the Customer list to the DTStamp on past transactions across 3 relationships in my schema. For context into the data relationships and tables I am working with:

1. tblCustomers connects to tblCustomerProduct by an intCustomerID key.
2. tblCustomerProduct connects to tblSales by a intProductID key. (tblSales also contains an intTransactionID column)
3. tblSales connects to tblTransactions by the intTransactionID key which is where the DTStamp resides

 

This is where I feel so far out of my depth. I can't fathom how to connect the CustomerID to the Transactions. I have tried ChatGPT, YouTube, UDemy to understand how to nest RELATED or RELATEDTABLE functions to capture all the relationships. My research is making me believe I need to create a series of measures to pull into a visualization? Truth be told, I am in dire need of expert insight! 

 

Thank you for taking the time to read this.

7 REPLIES 7
DataNinja777
Super User
Super User

@RYZGreg,

 

It sounds like your 'tblTransactions' is the smallest granurality data in your data model. My questions are as follows:

 

  • Is the Account Manager information contained in the customer master data dimension table which doesn't have time dimension information (change of Account managers over time to different customer assigment is not reflected in the current version of the customer master table as of today I guess.)  In order to obtain the correct information over time of which Account Manager was in charge of which customer, you need the Account Manager information (Account manager ID) in the transaction fact table which has transaction date information. 
  • What is the reason why tblTransactions and tblSales are separated out? Is this due to the size of tblTransactions is too big, and tblSales is a summarized version of tblTransactions with some information missing like DTStamp? My impression is that if you need to analyze Account Manager information by the granurality of DTStamp properly, Account Manager information has to be present in the tblTransactions where DTStamp resides, otherwise, arbitrary allocation will have to be applied.  

I am also interested in knowing what DTStamp stands for.  

Thank you kindly for your response, @DataNinja777 . To answer your questions:

1. The AccountManagerID is located in tblCustomers and is related to the tblAdminUsers table using a one-to-many relationships. Our Account Managers support roughly 500 customers. I believe I have the Customer List slicing appropriately. Where I am lost is tying the transactions to the customers. It doesn't particularly matter to me who was the Account Manager at the given point in time and more, how many transactions did that customer have.

2. Correct, Sales contains which Product and the TransactionID which then relates to the Transaction table using this ID. The transaction table then holds the status & date.
3. DTS stands for Date/Time Stamp.

 

Thanks again for your help so far! Interested if this additional context sheds further light on a suggested solution? 

Hi @RYZGreg 

If you do not care about who was the Account Manager at the given point in time, this task doesn't sound that complicated, because you can just use the current customer master data to identify the current Account manager to identify his customer's past transaction history, (which could have been taken care of by a different Account manager who might have subsequently left the company, or reassigned to different customers.)  You mentioned that tblCustomerProduct connects to tblSales by a intProductID key, but would you be able to download the sales and transaction data with customer ID key in addition to intProductID key, so that you can create direct relationship with customer master data table?   Companies' transaction data normally have sales and transaction information with customer ID information directly associatable with customer master data, so I assume you should be able to download such information without secondary association via intProductID key.   

Apologies for the delayed response - I have been out on paternity leave. I agree, It doesn't seem like it should be complicated to me either. Surely it's really common to have data points like this separated by foreign key relationships? Where I currently stand, I have all the relationships linked, my rolling calendar slicing the data and the Account Executive filtering the customer list. To answer your question, I don't have 'download' access to the data per se, I just have a directquery link to our database so I am having to navigate existing table relationships in my DAX measures. My outstanding question would be, what series of DAX measures would I need to create to obtain the # of transactions a customer has had in a time frame? 

Mahesh0016
Super User
Super User

@RYZGreg I hope this helps you.

I understand your challenge, and Power BI can be complex, especially when dealing with multiple table relationships. To achieve your objective of creating a visualization that allows account managers to filter their customer list by a specific date to determine if their customers processed transactions in a previous month/year, you'll indeed need to use DAX measures. I'll guide you through the steps to achieve this:

**Step 1: Create a Date Table**

First, ensure that you have a Date table that contains a sequence of dates covering the relevant date range. This Date table will help in creating time-based calculations. You can use the "CALENDAR" function in Power Query to generate a Date table or create it manually.

**Step 2: Create DAX Measures**

Now, you'll need to create several DAX measures to capture the required information. I'll provide you with a few example measures:

**Measure 1: Total Transactions for Selected Date Range**
```DAX
Total Transactions =
COUNTROWS(
FILTER(
tblTransactions,
tblTransactions[DTStamp] >= MIN('Date Table'[Date]) &&
tblTransactions[DTStamp] <= MAX('Date Table'[Date])
)
)
```
This measure calculates the total number of transactions within the selected date range.

**Measure 2: Customers with Transactions in Previous Month/Year**
```DAX
Customers with Transactions in Prev Month/Year =
VAR SelectedDate = MAX('Date Table'[Date])
VAR PrevMonthYear = EDATE(SelectedDate, -1)
RETURN
COUNTROWS(
SUMMARIZE(
FILTER(
ALL(tblCustomers),
CALCULATE(
[Total Transactions],
FILTER(
ALL('Date Table'),
'Date Table'[Date] >= PrevMonthYear && 'Date Table'[Date] < SelectedDate
)
) > 0
),
tblCustomers[intCustomerID]
)
)
```
This measure counts customers who had transactions in the previous month/year based on the selected date.

**Step 3: Create Visualization**

Now, create a table or any other visualization in Power BI. Place the "Customers with Transactions in Prev Month/Year" measure in the Values section. Add a slicer for the Date field from your Date table and another slicer for the Account Manager. This will allow account managers to filter customers based on date and their own accounts.

With these measures and slicers in place, you should be able to achieve your objective. The "Customers with Transactions in Prev Month/Year" measure will show the count of customers meeting your criteria based on the selected date and account manager.

Remember that you might need to adjust these measures to fit your specific data model, column names, and relationships. Additionally, performance optimization may be needed for large datasets. Power BI can be complex, but with patience and practice, you'll become more proficient in creating meaningful insights from your data.

@Mahesh0016 

Measure 1 makes sense to me. Unfortunately I am getting an error message: 
"The MIN function only accepts a column reference as an argument" but I only have a column reference selected ('Date Table'[Date]).

Also the second measure seems very complex and the DAX function doesn't seem to accept line 13 where we're joining the two Date arguments with &&. 

My understanding of the FILTER function is that it is building a custom table using DAX. Is that correct? 

Thanks much. 
Please advise! 

@Mahesh0016 Thanks so much! This looks pretty similar to what I found in ChatGPT but I will give it a go and let you know if I have any further questions. 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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