Forum Discussion
DISTINCT count for first value DAX
- 6 years ago
Hi Anonymous ,
At first, you need to add an index column in the query editor.
Then you could create a new column to get the result.
Column = VAR a = CALCULATE ( FIRSTNONBLANK ( 'Table'[ID], 1 ), FILTER ( 'Table', 'Table'[Index] = EARLIER ( 'Table'[Index] ) - 1 ) ) RETURN IF ( a = 'Table'[ID], 0, 1 )
Distinct count function is there for this
https://docs.microsoft.com/en-us/dax/distinctcount-function-dax
M1= distinctcount(ID)
M1= Calculate (distinctcount(ID))
Have I missed something?
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 Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners/ba-p/890814
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p/881739
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601
it's giving the sum total ID or 1 value. or it's not ignoring the second value
- amitchandak6 years agoSuper User
If you need exact same display, what you have give. Then first need a unique ID . Add index column .
https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi
In new office ribbon, edit queries is transform data
Then create a column like
Column = if(ISBLANK( COUNTX(FILTER(countDistinct,countDistinct[ID] = EARLIER(countDistinct[ID]) && countDistinct[Index]<EARLIER(countDistinct[Index])),countDistinct[ID])),1,0)refer
https://www.dropbox.com/s/m5s2lg2jpe59nap/DistinctData.pbix?dl=0
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 Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners/ba-p/890814
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p/881739
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601.