Struggling with the syntax having reorganized my tables as recommended. my tables look like this
<tbody>
</tbody>
So far so good. However I also wanted to be able to count how many different vehicles the customer had brought in for MOT using unique RegNum. In this case he has brought the same vehicle twice so the answer should be 1. I have tried everything, but cannot work out how to calculate this. in my first version of the model I had the RegNum and customer details in the transaction table so could use.
I tried various things including this, but this just gave me the same as the MOT Count i.e. =2.
Is this possible or do I have to RegNum back into the transaction table and use say DISTINCTCOUNT(transactions[regnum])?
This is all new to me having a triple layer cake so any advice appreciated.
Mike
<tbody> </tbody> | ||||||||||||||||||||||||||||||||||||||||||||||||||
<tbody> </tbody> |
<tbody>
</tbody>
Code:
=sumx(RELATEDTABLE(Invoices),CALCULATE(COUNTROWS(Transactions),filter(Transactions,Transactions[INVNUM]=Invoices[INVNUM] && Transactions[Service]="MOT" )))
So far so good. However I also wanted to be able to count how many different vehicles the customer had brought in for MOT using unique RegNum. In this case he has brought the same vehicle twice so the answer should be 1. I have tried everything, but cannot work out how to calculate this. in my first version of the model I had the RegNum and customer details in the transaction table so could use.
Code:
=CALCULATE(DISTINCTCOUNT(Transactions[RegNum]),filter(Transactions,Transactions[Unique Customer]=Customers[Customer Code] && Transactions[Service]="MOT"))
I tried various things including this, but this just gave me the same as the MOT Count i.e. =2.
Code:
=sumx(RELATEDTABLE(Invoices),CALCULATE(DISTINCTCOUNT(Invoices[RegNum]),filter(Transactions,Transactions[INVNUM]=Invoices[INVNUM] && Transactions[Service]="MOT")))
Is this possible or do I have to RegNum back into the transaction table and use say DISTINCTCOUNT(transactions[regnum])?
This is all new to me having a triple layer cake so any advice appreciated.
Mike