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.
Hi,
I am struggling to do what I think should be a very simple calculation. I have two disconnected tables, Orders and Visits. Each of them shares a similar UserID column. It's called 'CustomerID' in Orders and 'UserID' in visits. Most values are the same, however not all IDs appear in both columns and I am unable to create a relationship between the two tables.
All that I am looking to do is create a calculated measure in the "Visits" column which counts the number of times each 'UserID' in visits appears in the 'CustomerID' column in Orders. This seems to be a very simple ask, but I am struggling to make this work in PowerBI. Does anyone have any suggestions?
Thanks in advance.
Solved! Go to Solution.
@jackj usually in scenarios like this you should have a common dimension table with a unique user id and link these two together, anyhow try the following expression to get the count:
Count =
CALCULATE (
COUNTROWS ( Customer ),
TREATAS ( VALUES ( Visits[UserId] ), Customer[CustomerId] )
)
Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
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.
@jackj same thing, just use different calculation
Count =
CALCULATE (
SUM ( Customers[Sales] ),
TREATAS ( VALUES ( Visits[UserId] ), Customer[CustomerId] )
)
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.
@jackj sorry not sure what is your question?
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.
In addition to counting, I want to be able to sum the sales value in "Orders" that corresponds to the selected user ID. Hope that clarifies.
@jackj usually in scenarios like this you should have a common dimension table with a unique user id and link these two together, anyhow try the following expression to get the count:
Count =
CALCULATE (
COUNTROWS ( Customer ),
TREATAS ( VALUES ( Visits[UserId] ), Customer[CustomerId] )
)
Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
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.
Thank you! This worked for the count. One other question - how could I do something similar to be able to do a sumif-like function rather than a count with this same data, i.e., taking the sum of sales in the "orders" table based on the userID from the "visits" table?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
84 | |
67 | |
60 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |