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
Anonymous
Not applicable

Custom column - Count of entries with a given filter per day

Hello,

 

I'm using Power BI to manage Timesheet reports.

I need to create a custom column which counts the number of entries per day for a given client. Once I have that number, I need to substract a total of 45min per day spread over all entries of that client.

 

Here is some sample data:

 

dateclienthours
06.10.2019A1
06.10.2019A2
06.10.2019B1.5
06.10.2019A3
06.10.2019C0.5
07.10.2019A4
07.10.2019A1
07.10.2019C3
08.10.2019A3
08.10.2019D1
08.10.2019A2
08.10.2019B0.5
08.10.2019A1.5

 

What I'm looking to get is this (using Client A for the count) :

 

dateclienthours count_per_dayhours v2
06.10.2019A1 30.75
06.10.2019A2 31.75
06.10.2019B1.5 31.5
06.10.2019A3 32.75
06.10.2019C0.5 30.5
07.10.2019A4 23.625
07.10.2019A1 20.625
07.10.2019C3 23
08.10.2019A3 32.75
08.10.2019D1 31
08.10.2019A2 31.75
08.10.2019B0.5 30.5
08.10.2019A1.5 31.25

 

The hours v2 is simple to get once I get the Count/day :

IF(Client = "A" THEN hoursv2 = hours-0.75/count_per_day ELSE hours)

 

How can I achieve this count as a new column ?

 

Thanks !

2 ACCEPTED SOLUTIONS
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

As  a calc column you can use

 

Column =
CALCULATE (
    COUNTROWS ( TableName ),
    ALLEXCEPT ( TableName, TableName[Dates] ),
    TableName[client] = "A"
)

Regards
Zubair

Please try my custom visuals

View solution in original post

@Anonymous 

 

As a custom Column in Power Query

 

=Table.RowCount(
Table.SelectRows(
    #"Changed Type",
     (x)=> x[date]=[date] and x[client]="A"
                )
               )

Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

As  a calc column you can use

 

Column =
CALCULATE (
    COUNTROWS ( TableName ),
    ALLEXCEPT ( TableName, TableName[Dates] ),
    TableName[client] = "A"
)

Regards
Zubair

Please try my custom visuals

@Anonymous 

 

As a custom Column in Power Query

 

=Table.RowCount(
Table.SelectRows(
    #"Changed Type",
     (x)=> x[date]=[date] and x[client]="A"
                )
               )

Regards
Zubair

Please try my custom visuals

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.