Forum Discussion
Count unique orderers
- Anonymous6 years ago
You can create the relationship in the Model pane of in Power BI (see image).
If you are unable to create the relationship, then your measure will need to use the LOOKUPVALUE. Try this:
Ordering Sites = COUNTROWS( SUMMARIZE( ADDCOLUMNS( 'Sales', "SiteID", LOOKUPVALUE(Terminal[SiteID], Terminal[TerminalID], Sales[TerminalID]) ), [SiteID] ) )
Hi Camargos, here's the layout of my sales table ( db_v_SalesProduct ) and my site table ( db_v_LookupSite ).
They appear to link on the [TerminalID] field, but as i say, each site will have multiple terminals.
How do i share a file with data?
- camargos886 years agoCommunity Champion
- Anonymous6 years agoNot applicable
Ah ok, I see. So each SiteID can have 1 or more TerminalIDs, and you want the measure to return the number of distinct SiteIDs for each ProdCode. Try this
Ordering Sites = COUNTROWS( SUMMARIZE( 'Sales', Sales[TerminalID], "SiteID", LOOKUPVALUE('Terminal'[SiteID], Terminal[TerminalID], 'Sales'[TerminalID]) ) )- thorpyuk6 years agoHelper III
Hi EylesIT, yes that's exactly what i want to do! I'm close with that code you posted - i've edited it to the correct table names, but i must have missed something, or misunderstood some of your code, as it's counting the total terminals rather than the total sites.
Here's what i've done:
CountOrds = COUNTROWS( SUMMARIZE( 'db_v_SalesProduct', db_v_SalesProduct[TerminalID], "SiteCode", LOOKUPVALUE('db_v_LookupSite'[SiteCode], 'db_v_LookupSite'[TerminalID], 'db_v_SalesProduct'[TerminalID]) ) )