A table of multiple values was supplied where a single value was expected

I need to wait for the data to refresh, which is over 6.5M rows.

I need to step away and come back to this tomorrow.

Thanks Melissa. I will be in contact again, no doubt.

Hi,

Iā€™ve managed to remove the non printable characters at the end of the name for [Terminal ID]. However, I am now getting an error which states that

The field ā€˜Purchase Start Date & Timeā€™ of the record wasnā€™t found.

This particular column is a calculated column.

Any ideas?

Can you translate that logic to M?

If not what is the DAX syntax for that CC?

Here is a link to the full PBIX.

https://drive.google.com/file/d/1yb_YXG_nRrm-1964OGJPqr_ACpcg0u4O/view?usp=sharing

@Melissa,

Ideally, I donā€™t even need Purchase Duration in the P&D Table, as I currently have something similar in Tariffs[Tariffs Duration]. What I need is for the blank entries of the Purchase End Date and Time to be populated based on the data.

Chris

I assumed that my DAX for a calculated column which works for P&D Purchases[Purchase Tariff Name], could just be substituted with ā€˜Tariffsā€™[Tariff Duration] as below. But it doesnā€™t work.

Purchase Tariff Name = CALCULATE(
VALUES( ā€˜Tariffsā€™[Tariff Duration] ) ,
FILTER( Tariffs ,
ā€˜P&D Purchasesā€™[Terminal ID] = ā€˜Tariffsā€™[Terminal ID ] &&
ā€˜P&D Purchasesā€™[Purchase Start Day Name] = ā€˜Tariffsā€™[Day Name] &&
ā€˜P&D Purchasesā€™[Purchase Start Date & Time] >= ā€˜Tariffsā€™[Tariff Start Date] &&
ā€˜P&D Purchasesā€™[Purchase Start Date & Time] <= ā€˜Tariffsā€™[Tariff End Date] &&
ā€˜P&D Purchasesā€™[Purchase Amount] >= ā€˜Tariffsā€™[Tariff Amount Start] &&
ā€˜P&D Purchasesā€™[Purchase Amount] <= ā€˜Tariffsā€™[Tariff Amount End] &&
( ( ā€˜P&D Purchasesā€™[Purchase Start Time] >= ā€˜Tariffsā€™[Tariff Start Time 1] * (1/24) &&
ā€˜P&D Purchasesā€™[Purchase Start Time] < ā€˜Tariffsā€™[Tariff End Time 1] * (1/24) ) ||
( ā€˜P&D Purchasesā€™[Purchase Start Time] >= ā€˜Tariffsā€™[Tariff Start Time 2] * (1/24) &&
ā€˜P&D Purchasesā€™[Purchase Start Time] < ā€˜Tariffsā€™[Tariff End Time 2] * (1/24) ) ) ) )

Hi @chrisgreenslade,

No that doesnā€™t work and hereā€™s why. If you lookup this record in P&D Purchases


.
Youā€™ll find that it matches these 2 records in your Tariffs

So the result is 1 distinct Tariff Name but 2 distinct Tariff Durationsā€¦
This overlap in date range is something you should resolve in your Tariffs dimension table.

Let me know how you want to handle this.

I think the Tariff End Date for M-HARD-1 in the first row should read 04-04-19, so that the tariff is unique. The Tariff duration is also incorrect and should be 10 hrs (not 13).

Does the DAX now calculate for Purchase Duration? The ultimate goal is to have a visual that shows cars entering and leaving a car park over the course of a day, week, etc.

Currently our data is nasty from a particular source, which means we donā€™t get a purchase start and end date. Otherwise, this would have been an easy exercise.

I need to fill in the blanks from the company that canā€™t provide the above, but also analyse car park occupancy throughout the day.

Itā€™s a nightmare.

Hi @chrisgreenslade,

I do agree with you thereā€¦

Hopefully you understand that before you move on, you need resolve all these types of issues in your data. Otherwise how can you expect a valid outcome when your dimension table contains records that are ā€˜wrongā€™ - no amount of M or DAX code can account for that.

Furthermore Iā€™d suggest to close this thread, now. Feel free to open a new topic once all issues with your data have been resolved.

Thank you.

3 Likes