Forum Discussion
Count Of Drivers
- 1 year ago
Suhel_Ansari - this should work for both a column and a measure. Just replace Table with your table name:
CALCULATE(COUNTROWS( Table), ALLEXCEPT(Table, Table[Driver Name] ))If I answered your question please mark my post as the solution, it helps others with the same challenge find the answer!
- 1 year ago
Hi Suhel_Ansari
Create Calculated column in the Fact_Contracts tableDriver Contract Count = CALCULATE(COUNTROWS(Fact_Contracts), ALLEXCEPT(Fact_Contracts, Fact_Contracts[Driver_key]))
and create measure in the Dim_Driver table
Driver Count(M) = IF(HASONEVALUE(Fact_Contracts[Driver_key]), //True Result CALCULATE(COUNTROWS(Fact_Contracts), FILTER(ALL(Fact_Contracts),Fact_Contracts[Driver_key] = MAX(Fact_Contracts[Driver_key]))), //False Result SUMX(VALUES(Fact_Contracts[Driver_key]), CALCULATE(COUNTROWS(Fact_Contracts))) )I am also attaching a .pbix file for your reference.
https://drive.google.com/file/d/1MHPeKgVecPhIaFDpby81DQg8G2nbVrgZ/view?usp=sharingThanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.
Hi Suhel_Ansari
In which context would like to achieve that? Also in a table ?
As you mentionned 2 tables, you have to use related
So the following code should help you
Driver Count =
COUNTROWS ( RELATEDTABLE ( 'Contracts' ) )
Just add it in the contract table
If it is not what you are trying to achieve, share with us a sample of your 2 tables 🙂
it's work for Calcuated colum but we need the measure as well. Thanks
- mark_endicott1 year agoSuper User
Suhel_Ansari - if this is a response to me.
You can use the same code, it will work in both a calculated column and a measure.
If I answered your question please mark my post as the solution, it helps others with the same challenge find the answer!