Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
New to writing DAX code and I have been stuck with this. I beleive it is simple as I can do it quickly with a for loop but in DAX not sure how to go about it.
Below is a sample table. The last column is not part of the data but an indicator of what gets counted.
I would like to count for each Asset Name the unique occurences of Asset Feature under a filter of Asset Environment = 'Cold'.
The desired result should be a count of 4.
Asset Name | Asset Feature | Asset Environment | Desired Outcome from counting function |
Asset1 | x | Cold | Gets counted |
Asset1 | x | Cold | Does not get counted since value 'x' occurs previously for this asset |
Asset1 | z | Cold | Gets counted |
Asset2 | y | Cold | Gets counted |
Asset2 | x | Cold | Gets counted even though 'x' exists in Asset 1. |
Asset3 | w | Hot | Does not get counted due to 'Hot' environment |
Thanks in advance!
Ali
Solved! Go to Solution.
Hello!
Measure =
VAR TableData =
SUMMARIZE(
FILTER(
'TableName',
TableName[Asset Environment] = "Cold"
),
'TableName'[Asset Name],
'TableName'[Asset Feature]
)
RETURN
COUNTROWS(TableData)
Hello!
Measure =
VAR TableData =
SUMMARIZE(
FILTER(
'TableName',
TableName[Asset Environment] = "Cold"
),
'TableName'[Asset Name],
'TableName'[Asset Feature]
)
RETURN
COUNTROWS(TableData)
Hello Again,
The solution works but I found an added layer of complexity when I went to implement on the actual data model I have.
My fact table (let's calll it Fact_Table) has the columns "Asset Feature" and "Asset Environment" but does not have the "Asset Name" column. Fact_Table also has a column "Activity_ID".
The Fact_Table is linked in the data model to another table (let's call it Activity_Table). Activity_Table has a one to many relationship with FACT_Table with primary key being “Activity_ID”.
Finally Activity_Table is linked to a third table (let’s call it Asset_Table). Activity_Table has a one to many relationship with Asset_Table with primary key being “Activity_ID” as well. In this Activity_Table is where the “Asset Name” is which is required for the counting as per my initial sample table.
I believe since the intermediate table Activity Table links the Fact_Table with the Asset_Table using that same “Activity_ID”, I should be able to modify the DAX code to achieve the desired result but it probably requires embedding yet another nested summarize or something of that sort.
Would be grateful if there is a solution!
Thanks
Ali
Can you please provide example data?
I tried to replicate the database as explained, but I got confused with the Activity ID
Thanks so much!
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
69 | |
64 | |
50 | |
36 | |
26 |
User | Count |
---|---|
86 | |
55 | |
44 | |
43 | |
36 |