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
hanswittoeck
Helper I
Helper I

Measure for Dynamic sum in variable interval

Hello

I need a total for a flexible time interval. Thos os the data model

1 table with dates, operator and worked hours

1 table indicating the start and end date, the operator and a som of the hours between start and stop

 

OperatordayWorked  startendoperatorsum Worked
OP12020-01-058  2020-01-062020-01-11OP1??
OP12020-01-067.5  2020-01-052020-01-11OP2??
OP12020-01-076      
OP12020-01-088.5      
OP12020-01-0910      
OP12020-01-107.5      
OP12020-01-114      
OP12020-01-128      
OP22020-01-0510      
OP22020-01-067.5      
OP22020-01-074      
OP22020-01-088      
OP22020-01-0910      
OP22020-01-107.5      
OP22020-01-114      
OP22020-01-128      

 

Any idea how this can be done?

 

Help is highly appriciated

Hans 

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @hanswittoeck 

You need a measure or a calculated column? If the second table is an actual table (rather than a visual), you can create a calculated column for Table2:

Calc_column =
CALCULATE (
    SUM ( Table1[Worked] ),
    FILTER (
        ALL ( Table1 ),
        Table1[day] >= Table2[Start] && Table1[day] <= Table2[End]
            && Table1[operator] >= Table2[operator]
    )
)

 Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs

Cheers 

SU18_powerbi_badge

View solution in original post

4 REPLIES 4
hanswittoeck
Helper I
Helper I

sorry for the others, but the first solution worked for me, so no need to try anythinh else that can be as valuable

 

Hans 

Greg_Deckler
Super User
Super User

Perhaps:

 

Table =
  GROUPBY(
    'Table',
    [Operator],
    "start",MINX(CURRENTGROUP(),[day]),
    "end",MAXX(CURRENTGROUP(),[day]),
    "sum",SUMX(CURRENTGROUP(),[Worked])
  )

@hanswittoeck , I'm with @AlB I wasn't sure if you wanted a DAX table, a table visualization or what exactly.

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
AlB
Super User
Super User

Hi @hanswittoeck 

You need a measure or a calculated column? If the second table is an actual table (rather than a visual), you can create a calculated column for Table2:

Calc_column =
CALCULATE (
    SUM ( Table1[Worked] ),
    FILTER (
        ALL ( Table1 ),
        Table1[day] >= Table2[Start] && Table1[day] <= Table2[End]
            && Table1[operator] >= Table2[operator]
    )
)

 Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs

Cheers 

SU18_powerbi_badge

Yes,

this one works, except for one glitch:

Table1[operator] >= Table2[operator]

should be '=' not '>='

 

But I'm sure you were only checking my perceptiveness 😉 

 

Thanks a lot for your help

Hans

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
Top Kudoed Authors