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
imminent
New Member

how to select date and use the date selected for other calculation

Hi, I am a new user in PBI, I am trying to figure something out. able 1 has only unique calendar dates, table 2 has multiple dates with sale numbers for comparison. These two tables are connected through model. 

 

I would like user to select a date through date slicer( this is currently through date dim) connected to table using model (date as unique key, one to many) and ;

I would like to calculate for 2 other dates bsed on user's selection, previous date, previous week date(to do this, how can it be done?)

 

Through user selected dates, I am would like to be able to compare day on day, numbers from fact table. 

 

 

2 REPLIES 2
Arul
Super User
Super User

@imminent ,

try these measures,

1. Previous Day

Previous day sales = 
CALCULATE(
    SUM(Sales[Sales]),
    PREVIOUSDAY('Date'[Date]))

2. Previous week
To get this done you need year and weekno column in your date dimension table,

Previous week sales = 
CALCULATE (
    SUM ( Sales[Sales] ),
    FILTER (
        ALL ( 'Date' ),
        'Date'[Year] = MAX ( 'Date'[Year] )
            && 'Date'[Weekno]
                = MAX ( 'Date'[Weekno] ) - 1
    )
)

Thanks,

Arul

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


TomMartens
Super User
Super User

Hey @imminent ,

 

I recommend reading this article: https://www.daxpatterns.com/time-patterns/

This article comprises almost everything that needs to be known about date calculations.

 

Hopefully, this helps to tackle your challenge.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.