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
NH2501
New Member

Total in period per line

Hi everyone,

 

I've tried to search and apply some solutions from the forum, but none worked for me.

 

I got a table with fields:

1. Case No.

2. Time Spend

3. Creation Date

 

I would like to calculate % participation of each case in a total time spent in a year when case was created.
But I cannot obtain the last figure - total time in a year of creation.

Data example:
Case No.   Time Spend   Creation Date    Total Time In Creation Year      % Time In Creation Year
01              1d                 01/01/21                    3d                                                    33%
02              2d                 01/01/21                    3d                                                    66%
03              3d                 01/01/22                    4d                                                   75%
03              1d                 01/01/22                    4d                                                    25%

Of course totaling of the last column should give 100% in each year.

1 ACCEPTED SOLUTION

@NH2501 
Ok. The example from the original post gave the imprettion that the Creation Date column is allways the start of year date. 
Now you may try two methods. 
Method 1:

 

Total Time In Creation Year =
CALCULATE (
    SUM ( TableName[Time Spend] ),
    ALLEXCEPT ( TableName, TableName[Creation Date].[Year] )
)

 

Method 2:

First Create a new column for the Year: 

Year = YEAR ( TableName[Creation Date] )

Then

Total Time In Creation Year =
CALCULATE (
    SUM ( TableName[Time Spend] ),
    ALLEXCEPT ( TableName, TableName[Year] )
)

View solution in original post

5 REPLIES 5
NH2501
New Member

Nailed it! Thank you for help.

NH2501
New Member

Hi,

Thank you for suggestion, but it doesn't do the job, as limits the sum to the particular date, not the period (year in this case).

NH2501_0-1661951968341.png

 

@NH2501 
I see only 4 different dates! actually 4 different rows with absoluteley nothing in common.

 

@NH2501 
Ok. The example from the original post gave the imprettion that the Creation Date column is allways the start of year date. 
Now you may try two methods. 
Method 1:

 

Total Time In Creation Year =
CALCULATE (
    SUM ( TableName[Time Spend] ),
    ALLEXCEPT ( TableName, TableName[Creation Date].[Year] )
)

 

Method 2:

First Create a new column for the Year: 

Year = YEAR ( TableName[Creation Date] )

Then

Total Time In Creation Year =
CALCULATE (
    SUM ( TableName[Time Spend] ),
    ALLEXCEPT ( TableName, TableName[Year] )
)
tamerj1
Super User
Super User

Hi @NH2501 
I assume Time Spend of an integer data type, then

Total Time In Creation Year =
CALCULATE ( SUM ( TableName[Time Spend] ), ALLEXCEPT ( TableName[Creation Date] ) )

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.

Top Solution Authors