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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
rpattan
Advocate I
Advocate I

Time Intelligence - All periods comparison in one DAX formula

 

Hi There,

 

Could we have a single DAX formula for 'Time Intelligence' which may cover all of the below requirement in one shot rather than many while slicing and dicing...!

 

1. Monthly periods should compare with the previous month.

2. Quarterly periods should compare with the previous quarter.

3. Yearly periods should compare with the previous year.

4. Quarter-to-date periods should compare with the previous quarter.

5. Year-to-date periods should compare with the previous year.

6. Custom date ranges shouldn’t compare with a previous period.

 

My knowledge is upto building a single criteria based formula. Thanks in advance.

 

Regards,

Riyaz

1 ACCEPTED SOLUTION
rpattan
Advocate I
Advocate I

13 REPLIES 13
rpattan
Advocate I
Advocate I

Hi All,

 

Please find the solution for this query at below link.

 

http://community.powerbi.com/t5/Desktop/COMPARISON-Current-Period-sum-Vs-Previous-Period-sum-Change/...

 

Thanks

 

rpattan
Advocate I
Advocate I

Dear Folks,

 

Could some one spend a bit of time on the need. THANK YOU.

 

Riyaz

rpattan
Advocate I
Advocate I

 

Could some one look into the need.

 

Thanks

Riyaz

Floriankx
Solution Sage
Solution Sage

Hello,

 

I assume you have a separate DateTable with contigous dates?

for monthly, quartely and yearly periods compared to period before this might work:

 

 

Value:=Sum(Table[Values])

 

 

 

Value_PreviousPeriod:=
IF(HASONEVALUE(DateTable[Year]),
IF(HASONEVALUE(DateTable[Quarter]),
IF(HASONEVALUE(DateTable[Month]), //True HOV[Quarter]
CALCULATE([Value],DATEADD(DateTabe,-1,month), //True HOV[Month]
CALCULATE([Value],DATEADD(DateTabe,-1,quarter)), //False HOV[Month]
CALCULATE([Value],DATEADD(DateTabe,-1,year)), //False HOV[Quarter
Blank())

 

You could use similar Syntax to create a ToDate Value

 

 

Value_PeriodTD:=
IF(HASONEVALUE(DateTable[Year]),
IF(HASONEVALUE(DateTable[Quarter]),
IF(HASONEVALUE(DateTable[Month]), //True HOV[Quarter]
TOTALMTD([Value],DateTable) //True HOV[Month]
TOTALQTD([Value],DateTable) //False HOV[Month]
TOTALYTD([Value],DateTable) //False HOV[Quarter
Blank())

 You could add another level to check if a single day is selected, but you should try this first.

@Floriankx

 

Thank you for commenting.

 

Could you correct me;

 

Value_PreviousPeriod =
IF(HASONEVALUE('Date'[Date].[Year]),
IF(HASONEVALUE('Date'[Date].[Quarter]),
IF(HASONEVALUE('Date'[Date].[Month]), //True HOV[Quarter]
CALCULATE([Value],DATEADD('Date'[Date],-1,month), //True HOV[Month]
CALCULATE([Value],DATEADD('Date'[Date],-1,quarter)), //False HOV[Month]
CALCULATE([Value],DATEADD('Date'[Date],-1,year)), //False HOV[Quarter
Blank()))))

 

Errior Message:

A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

 

Thanks

Riyaz

Hello,

 

my bad!

 

Value_PreviousPeriod =
IF(HASONEVALUE('Date'[Date].[Year]),
IF(HASONEVALUE('Date'[Date].[Quarter]),
IF(HASONEVALUE('Date'[Date].[Month]), //True HOV[Quarter]
CALCULATE([Value],DATEADD('Date'[Date],-1,month)), //True HOV[Month]
CALCULATE([Value],DATEADD('Date'[Date],-1,quarter))), //False HOV[Month]
CALCULATE([Value],DATEADD('Date'[Date],-1,year))), //False HOV[Quarter
Blank())

 

This should be better.

@Floriankx

 

 

The given formula has no error shown, my pardon that it gives result as blank. Could you spare some more time on this.

 

https://drive.google.com/file/d/156PBYM7WEDj6thG9jgTGO4n6TsQ0YR55/view?usp=sharing

 

Ediable pbix is provided. Thanks

Riyaz

Hello I'm supporting during work. 

 

IT restrictions prohibit access to cloud services. I'm sorry.

@Floriankx

 

Thank you for your time.

Greg_Deckler
Super User
Super User

Might be possible. Can you give me a sense of your data? What do you have in your Calendar/Date table?



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hi,

 

@Greg_Deckler

 

Here is the data sample. Please to look. Thanks

 

 

TitleBadge TitleBadge TypeBadge Given ByBadge Created DateUser Sys IDDivisionCOUNT
CoE ManagerHappy CustomersCustom2010000077/31/2017 7:16301000019Delivery (Del)1
CoE ManagerHappy CustomersCustom2010000077/31/2017 7:16301000019Delivery (Del)1
CoE ManagerDrives ResultsCustom1010005067/31/2017 8:02301000019Delivery (Del)1
CoE ManagerCollaboratesCustom1010002908/3/2017 14:14301000019Delivery (Del)1
CoE ManagerDevelops TalentCustom1010004909/15/2017 15:45301000019Delivery (Del)1
CoE ManagerCollaboratesCustom10100046310/13/2017 7:43301000019Delivery (Del)1
CoE ManagerHappy CustomersCustom20100000110/13/2017 11:12301000019Delivery (Del)1
CoE ManagerTeam PlayerCustom10100029010/13/2017 19:38301000019Delivery (Del)1
CoE ManagerHappy CustomersCustom20100000111/15/2017 7:25301000019Delivery (Del)1
CoE ManagerCollaboratesCustom10100031611/30/2017 12:40301000019Delivery (Del)1
CoE ManagerDevelops TalentCustom10100049012/4/2017 2:04301000019Delivery (Del)1

 

 

@Greg_Deckler

 

Thanks for your valueble time. 

 

Link:

https://drive.google.com/file/d/1vAexcS1WUHtpR5F3jcGjCMBHLtGBHrju/view?usp=sharing

 

The link will give you an editable PBIX file. And in the file there are "PoP change" (Period on Period) percentages available, of which the respective percentages are not changing while selecting the month, quarter and year and so on. 

 

Your suggestion could be an answer to many users like me. 

 

THANKs

Riyaz

 

 

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.