# Measure not affected by date

Hi together,

I have the following issue;
I have a fact table with tonnage from different facilities and different months.
I have another table which contains the facilities and an energy factor per facility.

The desired output is a dynamic measure showing the average energy factor by ton.
So “sum of tonnage by facility multiplied by energy factor” divided by “sum of tonnage”

I made the calculation however the output is static and not influenced by the date when added into the visual.
I believe this is a rather easy issue but I fail to see what is wrong as both sums/sum measures are affected by the date but then the next measure is not.

Cheers,
Seb

Example.pbix (91.0 KB)

The issue here is that you only have two dates, January 1 and February 1, in your fact table. Therefore the way you have your measures structured, the visual will only show non-null observations on those dates.

If you’re looking to spread the value across the dates in between those two endpoints, you will need to implement an explicit allocation methodology within your measures or within Power Query. If you can provide a mockup of the specific result you’d like to see, I can show you how to implement that.

Also, a couple of other items of note:

1. you need to mark your date table (“invoked function”, and I recommend changing the name on that to Dates) in order for time intelligence functions to work properly.

3. whenever you are dividing two measures, use the DIVIDE function rather than the “/”. This will prevent an error when the denominator manager evaluates to zero.

– Brian

3 Likes

@BrianJ

Thanks for the feedback Brian;
In my original file I have much more data spreading multiple months, just updated the example file according to your inputs.
I noticed during this that my initial calculation seems to be the issue, it takes the total sum of the factor from the mapping table, however I need the measure to take the sum tonnage of facility A multiplied by the factor for A from the mapping table, then tonnage of B multiplied by energy factor for B and so on and then sum up the total, so it has to be an iterating function of some form and not SUM.

Sorry that my initial explanation was insufficient.

Cheers,
Seb
Example.pbix (93.9 KB)

I think I figured it out myself now by using the following measure:

Sum tonnage x factor = SUMX(‘Fact table’, ‘Fact table’[Tonnage] * RELATED(Mapping[Factor]))

Thanks anyway though @BrianJ , next time I sleep over it again and have a look with some fresh eyes.

Kind regards,
Seb

Exactly right – putting it inside the SUMX iterator calculates the product line by line and then sums over the identified table.

– Brian