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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Need to Calculate Current Date, Previous Date, Last year current date and last year previous date

Hello Everyone,

 

I am new to Power BI, aplogies if this question already been asked

 

i have below requirement 

 

i have date column and two measures

 

consider today is 03-06-2020

 

i need to create table by using date column as column header and measures are row headers like below 

 

                  Current Date     Previous Date      Last Year Current Date    Last Year Previous Date 

                   03-06-2020      03-05-2020                 03-06-2019                  03-05-2019

 

Measure 1        123                   345                              345                             555

 

Measure 2         234                   345                              321                             223

 

 

Thanks in advance

 

@PowerBI @desktop 

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

You could create a disconnected table. Then you measure could calculate differently based on the category. So, perhaps create a table like below using Enter Data query

 

Table: Categories

Category

Current Date

Previous Date

Last Year Current Date

Last Year Previous Date

 

Measure 1 = 

  VAR __Catetory = MAX('Categories'[Category])

  SWITCH(__Category,

    "Current Date",SUMX(FILTER('Table',[Date] = TODAY()),'Table'[Value]),

    "Previous Date",SUMX(FILTER('Table',[Date] = (TODAY() -1) *1.),'Table'[Value]),

...

 

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

Make sure you have a date table.

Sales = CALCULATE(SUM(Sales[Sales Amount]),'Date'[Date])
yesterday Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Day))

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

yesterday Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd(dateadd('Date'[Date],-1,Year),-1,Day))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thank you so much for very quick response,

 

I created date calender and joined with my date column, however when i used same calculation

for each date from date table i am getting same value, Please help me how i get value only for current date

 

Thanks & Regards

SV

@Anonymous Can you share sample data and sample output.make me @

Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors