Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
samwhich
New Member

Splitting a count on field from an when value 'IN'

Hi,

 

In my set of data I have a fact table of tasks. 

An asset gets inspected on a particular 'task code' and that 'task status' goes to completed and raises various other outstanding task codes.

 

The goal is to see what was inspected and the count of particular 'task codes' raised.

My count is correct and displays. But when I try to drag the 'task code' field into the legend of the visualisation it loses the count.

 

Monthly Simple - Power BI Desktop_2018-02-14_19-04-09.jpgMonthly Simple - Power BI Desktop_2018-02-14_19-05-19.jpg

 

If I change it to a table and split by asset and make another visualisation with just task code - when i click on an asset in the table it will fillter the separate task code visual, listing the completed inspection task as well as the raised tasks against the asset.

 

Measures I am using:

Assets That Had Inspections (VALUES) = CALCULATE(DISTINCT(Task[Asset_ID]),
USERELATIONSHIP('Date'[Date], Task[Completed_Date]),
FILTER(Task, Task[Task_Code] = "1001"))

 

Raised Tasks = CALCULATE(COUNT(Task[Work_Task_ID]),
FILTER(Asset, Asset[Asset_ID] IN {[Assets That Had Inspections (VALUES)]}),
USERELATIONSHIP('Date'[Date], Task[Created_Date]),
FILTER(Task, Task[Task_Status] = "O"))

 

And the SQL that does basically what I want:

SELECT task_code, COUNT(work_task_No) as Count
FROM work_tasks
WHERE Asset_ID IN (SELECT Asset_ID
FROM work_tasks WHERE Task_code = '1001')
AND task_status = 'O'
GROUP BY task_code

 

Any help appreciate, be gentle.

 

Cheers

 

1 REPLY 1
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @samwhich,

 

Please share sample data and illustrate desired output with examples.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.