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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
srinival
Helper I
Helper I

Count Data in Different Table with the State inforamtion

Hi Team,

 

We have two tables like below

 

Problem

Problem Task

 

Problem has unique column Problem Id and Problem Task has PTASK ID as unique and we have feild Parent in PTASK ID which carries Problem ID.

 

Now I am looking to create a calculated column to list Number of Problem Tasks for a Problem ID.

Also From the Problem Task Table, there is a column named state which have multiple states like (Open / Assigned / Work In Progress / Pending / Closed)

 

I would like to count for the Problem ID how many Tasks are Closed.

 

 

 

For Eg: 

 

IF the Problem ID : PID1000 has 7 Tasks as below

 

Problem Task Table:

 

PTASK ID        State                                Parent

PTASK1001     Work in Progress              PID1000

PTASK1002     Assigned                           PID1000

PTASK1003     Closed                              PID1000

PTASK1004     Closed                             PID1000

.

.

PTASK1007   Closed                              PID1000

 

 

In Problem Table I want to count the number of PTASKS for a Problem and also the PTASKS Closed out of them,

 

 

To Count the PTASKS I have used the DAX as below in Problem Table

 

Problem Table on Calculated Column as below

Tot PTASKs = COUNTROWS(RELATEDTABLE(PTASK))

 

 

Another Column :

 

CALCULATE(COUNTROWS(PTASK),FILTER(PTASK,PTASK[State]="Closed" || PTASK[State]="Resolved"))

 

But now i am not able see a single value, but i want this value to listed row wise based on the problem id 

 

I have created a One to Many Relation between Problem and Problem Task Table between Problem ID and Parent Field in PTASK Table.

 

Please advise how we can get the closed PTASKS Information

 

Appreciate your help.

 

Regards

Srini

1 ACCEPTED SOLUTION
daxer-almighty
Solution Sage
Solution Sage

[# Closed] = // calculated column in Problem
var __problem = Problem[ProblemID]
return
    COUNTROWS(
        FILTER(
            'Problem Task',
            'Problem Task'[ProblemId] = __problem
            &&
            'Problem Task'[State] IN {
                // if you want to use more
                // values, like "Resolved"
                // then stick it in here
                // after a comma.
                "Closed"
            }
        )
    )

View solution in original post

3 REPLIES 3
daxer-almighty
Solution Sage
Solution Sage

[# Closed] = // calculated column in Problem
var __problem = Problem[ProblemID]
return
    COUNTROWS(
        FILTER(
            'Problem Task',
            'Problem Task'[ProblemId] = __problem
            &&
            'Problem Task'[State] IN {
                // if you want to use more
                // values, like "Resolved"
                // then stick it in here
                // after a comma.
                "Closed"
            }
        )
    )

Hi

 

This has perfectly suits my requirement.

 

Thank you

 

Regrads

Srini

AntrikshSharma
Super User
Super User

Will you be able to share the PBI file?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.