Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
arq52
Frequent Visitor

measure with different offsets on date, depending on data coming from 2 facts table

Hello,
I have a task table, with due dates and quantities:
EXCEL_2020-10-27_00-35-45.png
A table of resources requested per task, different steps with the unit load and a number of days in advance of the due date:
EXCEL_2020-10-27_00-43-12.png
Current connections:
EXCEL_2020-10-27_01-01-17.png

I'm trying to calculate the workload by resource, per weeks generated by these tasks, thanks to the offset from the due date.

   * total load = UN_load * quantity
   * each of these loads positioned at ending date + offset
Expected "results" :

EXCEL_2020-10-27_00-47-19.png
I would know how to do this with powerquery, but with my actual datas, it would make me generate a results file of over 2 million records. I guess that it may be feasable with dax with 10 to 20 times less recordings.
Thank you in advance for your help.

1 ACCEPTED SOLUTION

@arq52  is this what you want?

wdx223_Daniel_0-1605150567132.png

Total Load :=
SUMX (
    CROSSJOIN (
        VALUES ( task[tasks] ),
        VALUES ( resource_per_task[resource] ),
        VALUES ( 'Calendar'[Date] )
    ),
    VAR _CurrentDate = 'Calendar'[Date]
    VAR _EndingDate =
        CALCULATE ( MIN ( schedule[ending date] ), 'Calendar'[Date] >= _CurrentDate )
    VAR _Offset =
        CALCULATE ( SUM ( resource_per_task[offset] ) )
    VAR _Load =
        CALCULATE ( SUM ( schedule[quantity] ), 'Calendar'[Date] = _EndingDate )
            * CALCULATE ( SUM ( resource_per_task[UN_load] ) )
    RETURN
        IF ( _CurrentDate = _EndingDate + _Offset, _Load )
)

View solution in original post

5 REPLIES 5
arq52
Frequent Visitor

Hello Daniel,

it's perfect!

EXCEL_Hyfv4xJaak.png

Now just to check the performance point of vue with my real datas.

Thanks again.

wdx223_Daniel
Super User
Super User

@arq52  i got the result you expected

wdx223_Daniel_0-1604623888977.png

Load_Date:=IF(COUNTROWS('resource_per_task')*COUNTROWS('schedule'),MAX('schedule'[ending date])+MAX('resource_per_task'[offset]))
****************************************
Total_Load:=IF(COUNTROWS('resource_per_task')*COUNTROWS('schedule'),MAX('schedule'[quantity])*MAX('resource_per_task'[UN_load]))

Thank you Daniel,

Not far from what I'm expecting, but I want to be able to do pivot table and link the load to the calendar date. With this measure, the load is linked to the ending date and not to the "load date":

EXCEL_rZkhVeZdAs.png

@arq52  is this what you want?

wdx223_Daniel_0-1605150567132.png

Total Load :=
SUMX (
    CROSSJOIN (
        VALUES ( task[tasks] ),
        VALUES ( resource_per_task[resource] ),
        VALUES ( 'Calendar'[Date] )
    ),
    VAR _CurrentDate = 'Calendar'[Date]
    VAR _EndingDate =
        CALCULATE ( MIN ( schedule[ending date] ), 'Calendar'[Date] >= _CurrentDate )
    VAR _Offset =
        CALCULATE ( SUM ( resource_per_task[offset] ) )
    VAR _Load =
        CALCULATE ( SUM ( schedule[quantity] ), 'Calendar'[Date] = _EndingDate )
            * CALCULATE ( SUM ( resource_per_task[UN_load] ) )
    RETURN
        IF ( _CurrentDate = _EndingDate + _Offset, _Load )
)
arq52
Frequent Visitor

Hi,

I have tryed

total load :=
SUMX (
  'schedule';
  'schedule'[quantity]
    * CALCULATE (
      VALUES ( 'ressource_per_tasks'[UN_load] );
      FILTER (
        'ressource_per_tasks';
        'ressource_per_tasks'[tasks] = 'schedule'[tasks]
      );
      FILTER (
        'Calendar';
        'Calendar'[date] = 'schedule'[ending date] + MAX('ressource_per_tasks'[offset])
    )
  )
)

With "MAX", I have "remove" an error about "not unique value for offset column".

But when I try to use the mesure in a pivot table, I get a "calculation error with the measure : a table with several values have been provided, but a unique value was expected".


Do you have an idee to solve that ?

Best regards

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.