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
bideveloper555
Helper IV
Helper IV

Count Distinct percentage group level

hi

i am working devops data set in power bi.If you are familiar with work items revision table.

i need to show percentage of sub group based on progress of the task. 

below is sample data set.

workitemidStatusTagnameiscurrent
1Activesqlyes
1Activesqlno
2Completedssisyes
3inprogressssrsyes
3inprogressssrsno
4completedsqlyes
4completedsqlno
5Activesqlyes
6Completedsqlyes
7activessisyes

after pivot

currentyes   
 sqlssisssrstotal
Active21 3
Completed21 3
inprogress  11

percentage 

 

currentyes   
 sqlssisssrstotla
Active50.00%50.00%0.00%42.86%
Completed50.00%50.00%0.00%42.86%
inprogress0.00%0.00%100.00%14.29%

 

What am trying to achive in power bi:

 

 a chart which can display percentage of completed items in tagname

or

showing total no. items per tagname with percentage of completed items.

 

example: for sql : chart will look like 4 items as total and 50% completed.

 

thanks

 

 

 

2 ACCEPTED SOLUTIONS
v-yiruan-msft
Community Support
Community Support

Hi @bideveloper555 ,

You can create a measure with below formula to get the completed percentage of per tag:

Completed % of per tag = 
VAR ccount =
    CALCULATE (
        DISTINCTCOUNT ( 'work items revision'[workitemid] ),
        FILTER (
            'work items revision',
            'work items revision'[Tagname] = MAX ( 'work items revision'[Tagname] )
                && 'work items revision'[Status] = "Completed"
                && 'work items revision'[iscurrent] = "Yes"
        )
    )
VAR fcount =
    CALCULATE (
        DISTINCTCOUNT ( 'work items revision'[workitemid] ),
        FILTER (
            'work items revision',
            'work items revision'[Tagname] = MAX ( 'work items revision'[Tagname] )
        )
    )
RETURN
    DIVIDE ( ccount, fcount )

completed percentage.JPG

Best Regards

Rena

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

View solution in original post

Hi @bideveloper555 ,

You can create a calculated column or measure with below formulas:

Measure = 
    IF (TODAY () >= MAX('Sprints'[Startdate])
        && TODAY () <= MAX('Sprints'[Enddate]),
    CONCATENATE ( "Current ", MAX('Sprints'[Sprint]) ),
    MAX('Sprints'[Sprint]))

or

Column = 
IF (
    TODAY () >= 'Sprints'[Startdate]
        && TODAY () <= 'Sprints'[Enddate],
    CONCATENATE ( "Current ", 'Sprints'[Sprint] ),
    'Sprints'[Sprint]
)

Different percentage group level count--case when.JPG

Best Regards

Rena

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

View solution in original post

6 REPLIES 6
v-yiruan-msft
Community Support
Community Support

Hi @bideveloper555 ,

You can create a measure with below formula to get the completed percentage of per tag:

Completed % of per tag = 
VAR ccount =
    CALCULATE (
        DISTINCTCOUNT ( 'work items revision'[workitemid] ),
        FILTER (
            'work items revision',
            'work items revision'[Tagname] = MAX ( 'work items revision'[Tagname] )
                && 'work items revision'[Status] = "Completed"
                && 'work items revision'[iscurrent] = "Yes"
        )
    )
VAR fcount =
    CALCULATE (
        DISTINCTCOUNT ( 'work items revision'[workitemid] ),
        FILTER (
            'work items revision',
            'work items revision'[Tagname] = MAX ( 'work items revision'[Tagname] )
        )
    )
RETURN
    DIVIDE ( ccount, fcount )

completed percentage.JPG

Best Regards

Rena

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

Thank you.

i will use this code.

am really sorry to be pain.

can i ask you bit of favour. How to convert SQL statment as below to DAX.

SQL statment : Case when getdate() between startdate and enddate then 'Current'+sprintname else sprintname END.

As i have few sprints (past,current and future) using current date, i need to deferentiate which sprint is current dynamically.

Example:

Sprint1

sprint2

sprint3

As of today sprint 2 is current sprint. but in week time,sprint 3 will be current.

Have a great day 🙂

Thanks.

Hi @bideveloper555 ,

You can create a calculated column or measure with below formulas:

Measure = 
    IF (TODAY () >= MAX('Sprints'[Startdate])
        && TODAY () <= MAX('Sprints'[Enddate]),
    CONCATENATE ( "Current ", MAX('Sprints'[Sprint]) ),
    MAX('Sprints'[Sprint]))

or

Column = 
IF (
    TODAY () >= 'Sprints'[Startdate]
        && TODAY () <= 'Sprints'[Enddate],
    CONCATENATE ( "Current ", 'Sprints'[Sprint] ),
    'Sprints'[Sprint]
)

Different percentage group level count--case when.JPG

Best Regards

Rena

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

Hi

That's worked beautifully.

Is there way I can define previous sprint, current and future sprint based on start and end dates.

Below dates are as example.

1st of May to 5th May 1st sprint

6th May to 10th May previous sprint

11th May to 15 May current sprint

16th May to 20tj May 4th sprint.

But this will change as dates move on.

Thanks in advance.

I will look into those resource hopefully this week.

Thank you.

Is ther way i can convert SQL statment into DAX.

 

any resource to learn more about DAX(you would recommend)

Hi @bideveloper555,

There is no direct tool to convert SQL statement to DAX... I would suggest you to review the contents in the following websites for learning DAX:

https://dax.guide/

https://www.sqlbi.com/guides/dax/

https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns

Best Regards

Rena

Community Support Team _ Rena
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.