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

Allocating Number of Days out the their respective week periods

Here's what I'm trying to work through.

 

I injury data where I have the occurance date and the number of days away from work.

 

i.e. Occurance Date: 1/1/2020, Days Away: 54

 

My goal is to allocate the number of days out their respective weeks.

 

I've not been successfull to this point and am open to suggestions.

 

Thanks,

Paul

4 REPLIES 4
AlB
Super User
Super User

@Anonymous 

See the attached file for a possible solutions. I am not getting the same results as the output you show. You might have to tweak the DateT table to have the exact weekn numbers you need.

Days away = 
VAR auxT_ =
    ADDCOLUMNS (
        SUMMARIZE (
            Table1,
            Table1[Case Number],
            Table1[Occurance Date],
            Table1[Days Out of Work]
        ),
        "@res",
            VAR daysOut_ =
                DATESBETWEEN (
                    DateT[Date],
                    [Occurance Date],
                    [Occurance Date] + [Days Out of Work] - 1
                )
            VAR daysInWeek_ =
                DISTINCT ( DateT[Date] )
            RETURN
                COUNTROWS ( INTERSECT ( daysOut_, daysInWeek_ ) )
    )
RETURN
    SUMX ( auxT_, [@res] ) + 0

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Anonymous
Not applicable

It's a great start, thank you.

 

I noticed where the data added up correctly, yet I'm seeing some discrepencies.

 

In this example, the location total is correct, yet when looking at fiscal month for within a fiscal year matrix the numbers don't add up.

plymburner2_0-1624303177209.png

When looking back previous years, the variance increases and it's always lower than the actual. I'd expect any the distributed value to be higher due to carry over.

 

I renamed the measure you provided as Dist Days Away

 

plymburner2_1-1624303462672.png

 

Anonymous
Not applicable

Original Data

Case NumberLocationOccurance DateDays Out of Work
11001/1/202040
21011/20/202025
31002/2/202090
41022/15/202020
51012/15/202015

 

Output

Assumptions:

Fiscal Year Starts: 1/1/2020

Fiscal Week Starts: 1/1/2020

*I'm using a fiscal date table in my data model.

 

Week NumberLocationDays Away
11007
1101 
1102 
21007
21011
2102 
31007
31017
3102 
410014
41017
4102 
51007
51017
5102 
61007
61018
61026
AlB
Super User
Super User

Hi @Anonymous 

Your request is  a bit vague. It would help if you can show some sample input data and, especially, the exact output you want for it.  Do you want the results in a table with all the weeks? How exactly? In a visual? How? other options?

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

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.