Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

How to create a measure that shows total count of rows from the dataset in a filtered table?

My dataset has 371 rows in it.  A table that I created and filtered shows 103 rows.  After adding the appropriate columns, I have different counts for my data categories such as A = 1, B = 2, C = 10, D = 0, etc.  How do I create a measure that shows the total count of the table data, 103?  The goal is to find the percentage of A, B, C, D, etc. 

2 ACCEPTED SOLUTIONS
az38
Community Champion
Community Champion

@Anonymous 

try

CALCULATE( COUNTROWS('Table'), ALL('Table'), 'Table'[Period] <> "Future")

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

View solution in original post

hi  @Anonymous 

Please try this:

Denominator = CALCULATE( COUNTROWS('Table'), FILTER(ALL('Table'),'Table'[Period] <> "Future"))

or 

Denominator = CALCULATE( COUNTROWS('Table'), FILTER(ALLSELECTED('Table'),'Table'[Period] <> "Future"))

 

https://www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept/

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Thank you, @az38 and @v-lili6-msft !  Both of your suggestions worked.

az38
Community Champion
Community Champion

Hi @Anonymous 

try smth like

Measure = DIVIDE(
CALCULATE(COUNTROWS(Table), ALLEXCEPT(Table, Table[Category]) ),
CALCULATE(COUNTROWS(Table))
)

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

Thanks for replying, @az38 .  Can you help me with the measure for just the denominator?  My dataset has a column for Period which has the possible values of "Future", "Current Month", and "Last 11 Months".  I want to set the denominator equal to the number of rows where the Period equals "Current Month" OR "Past 11 Months", or to put another way where Period is NOT equal to "Future".

 

I tried the formula Denominator = CALCULATE( COUNTROWS('Table'), ALLEXCEPT ('Table'[Period] <> "Future")) but that returned a syntax error.

hi  @Anonymous 

Please try this:

Denominator = CALCULATE( COUNTROWS('Table'), FILTER(ALL('Table'),'Table'[Period] <> "Future"))

or 

Denominator = CALCULATE( COUNTROWS('Table'), FILTER(ALLSELECTED('Table'),'Table'[Period] <> "Future"))

 

https://www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept/

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
az38
Community Champion
Community Champion

@Anonymous 

try

CALCULATE( COUNTROWS('Table'), ALL('Table'), 'Table'[Period] <> "Future")

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

Helpful resources

Announcements
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.