cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
samwhich Occasional Visitor
Occasional Visitor

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
Microsoft v-yulgu-msft
Microsoft

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

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
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

January 2020 Community Highlights

January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

Top Solution Authors