Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hello
I am currently investigating a dataset that contains the following columns below. The table refers to a series of assets that appear in a dataset if they have been verified to have failed inspection.
Asset ID | Date of entry |
AK-0001 | 02-03-2019 |
AK-0013 | 05-03-2020 |
AK-0321 | 17-03-2020 |
AK-0001 | 17-03-2020 |
AK-0013 | 21-03-2020 |
AK-0013 | 24-04-2020 |
AK-0001 | 30-03-2020 |
I'm trying to use DAX to create a new variable/measure that calculates the number of repeat errors. A repeat error would be defined as:
- The same asset (identified by Asset ID) failing three or more times...
- ... within a12-week period
Therefore, when examining the previous dataset, the AK-0013 asset made a repeat error, as it failed three times in a 12-week period, but the AK-0001 asset has zero repeat errors even if it failed three times separately, because the errors occurred over a period longer than 12 weeks.
I have used DAX several times before for different measurements and have always searched Google intensely before asking in the community (depending on the keywords). However, this is the first time I am perplexed and will gladly welcome you to any help and advice on how to create this measure! If you have any questions or require further elaboration please ask.
Thanks a lot
apb_123
Solved! Go to Solution.
Hi @Anonymous ,
Create 2 measures as below:
Measure =
var _totalrows=CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Asset ID]=MAX('Table'[Asset ID])))
var _mindate=MINX(FILTER(ALL('Table'),'Table'[Asset ID]=MAX('Table'[Asset ID])&&'Table'[Date of entry]<MAX('Table'[Date of entry])),'Table'[Date of entry])
var c=DATEDIFF(_mindate,MAX('Table'[Date of entry]),WEEK)
Return
IF(_totalrows>=3 && c<12,"repeat error",BLANK())
Repeat error =
var a =CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Asset ID]=MAX('Table'[Asset ID])))
var b=CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Asset ID]=MAX('Table'[Asset ID])&&'Table'[Measure]<>BLANK()))
var c=IF(a>=3&&a-b<2,1,0) Return
SUMX(FILTER(ALL('Table'),'Table'[Asset ID]=MAX('Table'[Asset ID])),c)
Finally you will see:
For the related .pbix file,pls click here.
Hi @Anonymous ,
Create 2 measures as below:
Measure =
var _totalrows=CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Asset ID]=MAX('Table'[Asset ID])))
var _mindate=MINX(FILTER(ALL('Table'),'Table'[Asset ID]=MAX('Table'[Asset ID])&&'Table'[Date of entry]<MAX('Table'[Date of entry])),'Table'[Date of entry])
var c=DATEDIFF(_mindate,MAX('Table'[Date of entry]),WEEK)
Return
IF(_totalrows>=3 && c<12,"repeat error",BLANK())
Repeat error =
var a =CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Asset ID]=MAX('Table'[Asset ID])))
var b=CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Asset ID]=MAX('Table'[Asset ID])&&'Table'[Measure]<>BLANK()))
var c=IF(a>=3&&a-b<2,1,0) Return
SUMX(FILTER(ALL('Table'),'Table'[Asset ID]=MAX('Table'[Asset ID])),c)
Finally you will see:
For the related .pbix file,pls click here.
@Anonymous
With help of date table and week Rank you can get 12 week data like this
Last 12 week Sales = CALCULATE(Count(Table[Asset ID]),FILTER(all('Date'),'Date'[Week Rank]>=min('Date'[Week Rank])-12 && 'Date'[Week Rank]<=max('Date'[Week Rank])))
You can filter on > 3
Refer, how to deal with the week