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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
janusd27
Frequent Visitor

Mesure avec date relative

 

Bonjour,
Je cherche avec une messure à récupérer le nombre de sollicitations, du derniers mois civil (fonction identique au filtre relative, dans les filtres visuels 


_NombreSollicitationLastMonth = CALCULATE([_NombreDeItemID]; DATESINPERIOD(Categorisations[Date_Creation];LASTDATE(Categorisations[Date_Creation];-1;MONTH)))

Pouvez vous m'aider sur cette recherche svp ?

 

Hello,
I am looking with a size to recover the number of requests, from the last calendar month (function identical to the relative filter, in the visual filters

Can you help me with this research please?
 
 
1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @janusd27 ,

 

If I understand you correctly, what you want to do is to calculate total of last month based on slicer.

Please check if this is what you want:

Last Month Total Measure = CALCULATE ( SUM ( 'Table'[Value] ), PREVIOUSMONTH ( 'Calendar'[Date] ) )

pre.gif

 

Best Regards,

Icey

 

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

View solution in original post

6 REPLIES 6
Icey
Community Support
Community Support

Hi @janusd27 ,

 

If I understand you correctly, what you want to do is to calculate total of last month based on slicer.

Please check if this is what you want:

Last Month Total Measure = CALCULATE ( SUM ( 'Table'[Value] ), PREVIOUSMONTH ( 'Calendar'[Date] ) )

pre.gif

 

Best Regards,

Icey

 

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

janusd27
Frequent Visitor

Thanks 🙂
amitchandak
Super User
Super User

I usually prefer datesmtd or totalmtd with calendar table.

Example

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))

 

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/

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Datanaut Connect on Linkedin

I wrote 

_NbrSollicitionLastMonth = CALCULATE(DISTINCTCOUNT(Categorisations[Changements]);DATESINPERIOD(Calendrier[Date];LASTDATE(Calendrier[Date]);1;month)) 


But he recovered the sum of the last 6 calendar months instead of the sum of the last calendar month

The must Is ??

_NombreSollicitationLastMonth = TOTALMTD(SUM(Categorisations[CHG_1]);PREVIOUSMONTH(Aujourd'hui ?))

I wrote :
_NombreSollicitationLastMonth = CALCULATE([_NombreDeItemID];DATESMTD(ENDOFMONTH(dateadd('Categorisations'[Date_Creation];-1;MONTH))))

 

 

Error Message:
MdxScript(Model) (11, 85) Erreur de calcul dans la mesure 'Categorisations'[_NombreSollicitationLastMonth] : Une colonne de date contenant des dates dupliquées a été spécifiée dans l'appel de la fonction « DATESMTD ». Cela n'est pas pris en charge.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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