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
ptk10636
Frequent Visitor

Running Total Showing Wrong Values

I am using the below function to calculate the 12 month running total of items.

When all the periods are listed every thing works great. However if I filter and a period is missing a MYSTERIOUS "2" appears in the data.


CompRunning_alt =
VAR CompCount =
   CALCULATE (
      DISTINCTCOUNT( 'Extract (Header)'[issueNumber]),
      DATESINPERIOD (
         'Extract (Header)'[Month],
         MAX ('Extract (Header)'[Month] ),
         -12,
         MONTH
      )
   )
RETURN
   CompCount

 

All Months

AllMonths.JPG

 

With missi

MissingMonths.JPG

1 ACCEPTED SOLUTION
ptk10636
Frequent Visitor

I was able to resolve the issue by adding a seperate date table and not use the date in the main table. I do not know why this fixed the problem or why PBI was putting a MYSTERIOUS 2 when it should have been Null or Zero.

View solution in original post

3 REPLIES 3
ptk10636
Frequent Visitor

I was able to resolve the issue by adding a seperate date table and not use the date in the main table. I do not know why this fixed the problem or why PBI was putting a MYSTERIOUS 2 when it should have been Null or Zero.

Ashish_Mathur
Super User
Super User

Hi,

I assume that Items is a measure which is calculated as = DISTINCTCOUNT( 'Extract (Header)'[issueNumber]).  If my understanding is correct, then how can you add distinctcount entries.  By its very nature, distinctcount cannot be additive.


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

@ptk10636 very hard to tell without looking at the pbix file, can you share it, remove sensitive info before sharing.

 

Also as a best practice, do all time-based calculation using date dimension, means you should add a date dimension in your model to make it work.

 

here is a blog post that talks about how to add a date dimension to your model.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.