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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.