March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
I have a table of campaigns. I want to add columns to my campaign table that contain the number of opportunities at each sales stage. I have a table of opportunities with columns for stage number and stage name.
Campaigns
Opportunities
These two table have a relationship
How can I add columns to the campaigns table that summarize the number of opportunities at each stage? I would add a column for each of the 9 sales stages: Investigate, Meet, Probe, Apply, Convince, Tie it up, Closed Won-Pending, Closed Won, Dead.
Thanks in advance for your help.
Jeff
Solved! Go to Solution.
I can't test it right now, but you have a bidirectional relationship, so you can make use of the RELATEDTABLE.
When you are in the CAMPAIGN table, the RELATEDTABLE function will return the rows in the OPPORTUNITY which are filtered, for each row.
So if you add a calculated column and use this code
rows=countrows(RELATEDTABLE(opportunity))
it will tell you the number of connected rows.
Now the trick is to filter them based on your stage, so (again without testing but should work), something in the line of
Rows in Stage Investigation=countrows(FILTER(relatedtable(opportunity);Stage="investigation")) or probably better Rows in stage investigation = calculatetable(opportunity;Stage="Investigation")
Hey,
I think you are looking for the LOOKUPVALUE function: https://dax.guide/lookupvalue/
If you have to aggregate multiple rows from the source table you can use something similar to this:
column name = var thisCampaignID = '<campaigntable>'[campaignid] return CALCULATE( SUM('<opportunitytable>'[colums]) FILTER( '<opportunitytable>' , '<opportunitytable>'[campaignid] = thisCampaignID ) )
Hopefully this is what you are looking for.
Regards,
Tom
I can't test it right now, but you have a bidirectional relationship, so you can make use of the RELATEDTABLE.
When you are in the CAMPAIGN table, the RELATEDTABLE function will return the rows in the OPPORTUNITY which are filtered, for each row.
So if you add a calculated column and use this code
rows=countrows(RELATEDTABLE(opportunity))
it will tell you the number of connected rows.
Now the trick is to filter them based on your stage, so (again without testing but should work), something in the line of
Rows in Stage Investigation=countrows(FILTER(relatedtable(opportunity);Stage="investigation")) or probably better Rows in stage investigation = calculatetable(opportunity;Stage="Investigation")
Thanks, Tom. I'm not sure that does what I need.
From the opportunity table I need to count the rows that contain a particular value from the stage number column. and put that value into a column into a row the campaigns table, based on the campaign ID.
Where would I apply the Dax you suggested? Would that be used to create a custom column in the quiery editor? Or would I use that to create a new column in the report?
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
129 | |
90 | |
75 | |
58 | |
53 |
User | Count |
---|---|
200 | |
104 | |
101 | |
67 | |
55 |