Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
SaChinKuMarT
Frequent Visitor

DAX formula to find the previous day count

Hi I need a solution to find the previous days count. Where if i click today's date it should show the Yesterday's result.

 

SaChinKuMarT_1-1680457169206.png

 

As an sample i have attached a screenshot here. 

 

Kindly help with your ideas thank you.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1680466493163.png

Selected day count measure: = 
COUNTROWS( Data )

 

Previous day count measure: = 
CALCULATE ( [Selected day count measure:], Data[Date] = MAX ( Data[Date] ) - 1 )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1680466493163.png

Selected day count measure: = 
COUNTROWS( Data )

 

Previous day count measure: = 
CALCULATE ( [Selected day count measure:], Data[Date] = MAX ( Data[Date] ) - 1 )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Thank you so much JIHWAN_Kim

hah, your solution looks simpler and faster than mine Jihwan. 😄

 

My only comment is I do still prefer SELECTEDVALUE to MAX because the measure only makes sense if exactly one date is selected.

Wilson_
Memorable Member
Memorable Member

Hello!

 

Try the below measure out and let me know whether it works for you or not. 😄

 

Yesterday Count = 
VAR Yesterday = SELECTEDVALUE ( Table1[Date] ) - 1

-- Filters your data for yesterday's row
VAR FilteredTable =
FILTER (
    ALL ( Table1 ),
    Table1[Date] = Yesterday
)

RETURN
SUMX (
    FilteredTable,
    Table1[Count]
)

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.