Forum Discussion
Need help on Creating a measure based on another table's Column
Hi Krishna1990_PBI ,
I may be oversimplifying this, but it looks like you just want to find out the number of computers that have an [ApplicationName] LIKE "CrowdStrike".
If so, then the following should work fine:
_AppCount =
CALCULATE(
DISTINCTCOUNT(Table2[ComputerID]),
CONTAINSSTRING(Table2[ApplicationName], "CrowdStrike")
)
As you have a Table1 ONE : MANY Table2 relationship, this should calculate correctly for different selections of Table1.
If you don't actually need the 'LIKE' comparison, but an 'EQUALS' comparison, then it's even simpler:
_AppCount =
CALCULATE(
DISTINCTCOUNT(Table2[ComputerID]),
Table2[ApplicationName] = "CrowdStrike"
)
Pete
Hi Pete.
Thanks for the reply.
I wanted to keep that measure value remain unchanged when I click any visuals from the board. Curently the value is changing.
Regards
Krishna G
- BA_Pete3 years agoSuper User
Ok, so the following should work:
_AppCount = CALCULATE( DISTINCTCOUNT(Table2[ComputerID]), FILTER( ALL(Table2), CONTAINSSTRING(Table2[ApplicationName], "CrowdStrike") ) ) // OR _AppCount = CALCULATE( DISTINCTCOUNT(Table2[ComputerID]), FILTER( ALL(Table2), Table2[ApplicationName] = "CrowdStrike" ) )Pete
- Krishna1990_PBI3 years agoNew Member
I wanted to query Table2 Application Column based on Table1 Computer ID. So i used the folowing query but the measure value changes
Should i go for calculated column to overcome this scenario
_AppCount = CALCULATE( DISTINCTCOUNT(Table1[ComputerID]), FILTER( ALL(Table2), CONTAINSSTRING(Table2[ApplicationName], "CrowdStrike") ) )- BA_Pete3 years agoSuper User
I'm struggling to understand why you need to involve Table1 in your measure.
You have [ComputerID] in Table2 that you can use to count, and you have a ONE:MANY relationship between the two tables, so all of Table1 is already included in the expanded version of Table2.
What am I missing here?
Pete