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
Susan_Colyn
Helper I
Helper I

Calculate last 9 months using DAX formula

Good day,

 

I have 1 table

with all my data from 2017.  We have kits which we must implement on equipment within 9 months and I would like to calculate the number of Total kits and No of kits implemented on time for the last 9 months.

 

I tried a few formulas but am not getting the correct result.

 

Here is an example of my table

DateCountryKit NumberEquip NoTotal On-Time
5 Sep 2019Turkey124569002511
12 Dec 2019Turkey156929002510
28 Dec 2019Egypt975239082510
9 Jan 2020Egypt697259082511
6 Feb 2020Turkey796529002511

 

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

Hi @Susan_Colyn 

try measures

Total kits = 
CALCULATE(DISTINCTCOUNT('Table'[Kit Number]), DATESBETWEEN('Table'[Date], DATEADD(TODAY(), -9, MONTH), TODAY()) )
No of kits implemented = 
CALCULATE(DISTINCTCOUNT('Table'[Kit Number]), DATESBETWEEN('Table'[Date], DATEADD(TODAY(), -9, MONTH), TODAY()), 'Table'[On-Time]=1)

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

2 REPLIES 2
az38
Community Champion
Community Champion

Hi @Susan_Colyn 

try measures

Total kits = 
CALCULATE(DISTINCTCOUNT('Table'[Kit Number]), DATESBETWEEN('Table'[Date], DATEADD(TODAY(), -9, MONTH), TODAY()) )
No of kits implemented = 
CALCULATE(DISTINCTCOUNT('Table'[Kit Number]), DATESBETWEEN('Table'[Date], DATEADD(TODAY(), -9, MONTH), TODAY()), 'Table'[On-Time]=1)

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hi @az38 Super User II

 

Thank you for the solution but I received an error with Dateadd, it seems you have to include a Field.  I added a date field and it worked.

Thank you very much for your help.

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.