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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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