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
Anonymous
Not applicable

Get count of previous date value.

Hey guys,

How to get the value count for a column for previous day and plot it in clustered column chart?

CountFromPreviousDay = CALCULATE(COUNT('Check table'[UID]),FILTER('Calendar',PREVIOUSDAY('Calendar'[DATES)))
I have a calendar table with all the dates and a check table with [Date] and [ID] column. I have ID incoming everyday except saturday and sunday. using the upper dax skips previous values for monday and friday. What is the ideal dax for this ?
 [Calendar Table] : has all dates
[CHECK TABLE] : skips sat and sun
dateid
09/06/221a
09/06/222a
09/06/223a
09/06/224a
10/06/222a
10/06/223a
10/06/224a
13/06/221a
13/06/222a
1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Create an index column:

index = RANKX('Table','Table'[date],,ASC,Dense)

Then create a measure like below:

Measure = CALCULATE(COUNT('Table'[id]),FILTER(ALLSELECTED('Table'),'Table'[index]=SELECTEDVALUE('Table'[index])-1))+0

vjaywmsft_0-1670226797612.png

 

 

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

3 REPLIES 3
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Create an index column:

index = RANKX('Table','Table'[date],,ASC,Dense)

Then create a measure like below:

Measure = CALCULATE(COUNT('Table'[id]),FILTER(ALLSELECTED('Table'),'Table'[index]=SELECTEDVALUE('Table'[index])-1))+0

vjaywmsft_0-1670226797612.png

 

 

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
Anonymous
Not applicable

Hi @amitchandak ,

thankyou for your reply. I tried your solution. Somehow it gives fridays value for saturday as [previousday value] and monday it doesn't give a previous day value.

ShubhamPandey_0-1669713003770.png

Regards,

Shubham

amitchandak
Super User
Super User

@Anonymous , Try like

 

CountFromPreviousDay = CALCULATE(COUNT('Check table'[UID]),PREVIOUSDAY('Calendar'[DATES))

 

 

Day Intelligence - Last day, last non continous day
https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c3243d1f9

 

check

http://dataap.org/blog/2019/04/22/difference-between-calculate-with-and-without-filter-expression/

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.