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

Trailing 12 month count error -single value for column 'Date' in table'Date' cannot be determine

OK I have two tables. Relevant here are: 'Item'[item_id],'Item'[activedate] (where each item_id is distinct/unique,) and 'Date'[date].
I have an inactive relationship between Item[activedate] and 'Date[date] just for this measure. It's inactive because 'Item'[item_id] is also related to a Sales table which is in turn related to 'Date[date], and it creates a conflict.

 

I am trying to create a 12 month trailing count of items, based on this 'Item'[activedate] for a rolling visual. For any given date, I want a count of all items with an active date between the given date and a date one year before the given date.  I have:


SKUCreation_12month_rollingCount = CALCULATE(count('Item'[item_id]),USERELATIONSHIP('Item'[activedate],'Date'[Date]),DATESBETWEEN('Item'[activedate], DATEADD('Date'[Date], -1, YEAR),'Date'[Date]))

Yields the error "A single value for column 'Date' in table'Date' cannot be determined..."

Any help is appreciated.

 

Thanx

 

Phil

 

 

 

1 ACCEPTED SOLUTION

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
PhilSmith
Helper I
Helper I

Lets change it to a 7 Day trailing count for simplicity.  I can extrapolate from there.  Remember the inactive relationship Item-Date, created that is different then the active relationship between Item-Sales, then Sales-Date.

The first table is a sample of data points in Item. The second table would be a table visual of the results, with Date and the measure I am trying to get to, 7DayTrailingCount. For any particular date, how many items have a active date in that 7 day trailing window from that Date. If the date is 1/8, then you would count both items with a activedate of 1/5, and the item with aactivedate of 1/3. If the date is 1/6, you would count both items with a activedate of 1/5, as well as 1/3 and 1/1.

Item Table Results Visual  
Item IDActivedate Date 7DayTrailingCount
12341/1/2023 1/1/2023 1
12351/3/2023 1/2/2023 1
12361/5/2023 1/3/2023 2
124371/5/2023 1/4/2023 2
124381/15/2023 1/5/2023 4
124391/19/2023 1/6/2023 4
   1/7/2023 4
   1/8/2023 3
   1/9/2023 3
   1/10/2023 2
   1/11/2023 2
   1/12/2023 0
   1/13/2023 0
   1/14/2023 0
   1/15/2023 1
   1/16/2023 1
   1/17/2023 1
   1/18/2023 1
   1/19/2023 2

 

 

 

I hope that clears things up?

 

Thanx

 

Phil

 

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you.  That directed me to the fix.

 

Phil

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@PhilSmith , if you need training 12 month

 

CALCULATE(CALCULATE(count('Item'[item_id]),USERELATIONSHIP('Item'[activedate],'Date'[Date])), DATEADD('Date'[Date], -1, YEAR))

 

for rolling 12

 

Rolling 12 = CALCULATE(CALCULATE(count('Item'[item_id]),USERELATIONSHIP('Item'[activedate],'Date'[Date])),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-12,MONTH))

Thank You.  You are correct, Trailing 12 months would be the more apt term for the measure here.    Both of these measures work, in that I do not get any errors, but neither of them supply any actual data.  If I line them up on a clustered column chart next to item_id (count) on the visual, I get counts over days as I would expect, but nothing surfaces for either measure.

Hi,

Very confused about what you want.  Share some data, describe the question and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.