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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
AlexisPREVOT
Resolver I
Resolver I

Problem with formula

Hi,

 

I am trying to determine my number of orders compared to a previous period.
Since my date table could not be clean, I proceeded in two stages: the first by creating a column allowing me to find the dates of my previous period :

 

Commande N-1 = DATEADD('Marketing COMMANDE'[DATE_COMMANDE].[Date],-1,YEAR)
 
And in the second step a measure allowing me to count my number of orders :
 
Nombre de commandes N-1 = CALCULATE(DISTINCTCOUNT('Marketing COMMANDE'[REFERENCE_COMMANDE]),FILTER(ALL('Marketing COMMANDE'[DATE_COMMANDE]),CONTAINS(VALUES('Marketing COMMANDE'[Commande N-1]),'Marketing COMMANDE'[Commande N-1],'Marketing COMMANDE'[DATE_COMMANDE])))
 

My problem is that it gives me an empty result.

Does anyone have an idea where the problem could come from?

I did exactly the same process on another table that has the same architecture and it didn't cause any problems.

 

Thank you by advance.

Alexis

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@AlexisPREVOT , You should always use date table for time intelligence function

 

CALCULATE(DISTINCTCOUNT('Marketing COMMANDE'[REFERENCE_COMMANDE]), dateadd('Date'[Date],-1, Year))

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA

 

Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs

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

View solution in original post

4 REPLIES 4
AlexisPREVOT
Resolver I
Resolver I

Hi @v-chenwuz-msft @amitchandak ,

 

Thank you for your answers. During my long weekend I studied the date tables more seriously and I was able to put them into practice. This actually solved my problem.

Thanks to you two.

amitchandak
Super User
Super User

@AlexisPREVOT , You should always use date table for time intelligence function

 

CALCULATE(DISTINCTCOUNT('Marketing COMMANDE'[REFERENCE_COMMANDE]), dateadd('Date'[Date],-1, Year))

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA

 

Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs

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

Thank you @amitchandak for your response.

 

I'm going to try this formula by creating a date table but I must be extremely useless because even if I manage to create this table without any problems, I'm completely lost for its use...

Hi  @AlexisPREVOT , 

 

Or you can calculate distinctcount without create a date table with your date column 'Marketing COMMANDE'[DATE_COMMANDE], but all() must be add if no date table.

 

Some measures like this.

Measure =
CALCULATE (
DISTINCTCOUNT ( 'Marketing COMMANDE'[REFERENCE_COMMANDE] ),
ALL ( 'Table' ),
DATEADD ( 'Marketing COMMANDE'[REFERENCE_COMMANDE], -1, YEAR )
)

 

Actually, the date table  @amitchandak  mentioned is used to filter the date column [DATE_COMMANDE]. Which has one to many relationship to your date column  [DATE_COMMANDE].

 

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.