cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Leon12Smith
Frequent Visitor

Count Rows of Joined Tables with multiple conditions

Hi

I am able to create this Table Visualisation in Power BI by dragging in columns from different tables and applying the appropriate filters in the Filters Pane on this specific Visual. The filters are obvious as per the table values but the only strange condition is Written Amount > 0. This results in 15x unique Product Numbers as per the table. I need a measure that can calculate the row count of the table below that equals 15 unique Product Numbers based on the filter conditions applied. 

Leon12Smith_0-1693683297150.png


The columns listed in the Table Visualisation are in the following tables in the database and there are active relationships (direct and indirect relationships - through other tables not listed) between these tables in the model:

1. Database Table A contains the following columns:
- Product Number
- Product Line
- Product Type
- Product Sub-Type
- Status
- Origin

2. Database Table B contains the following column:

- Period

3. Database Table C contains the following column:

- Direct or Indirect

4. Database Table D contains the following column:

- Written Movement

Please assist. I can't share the data.



1 ACCEPTED SOLUTION
Leon12Smith
Frequent Visitor

CALCULATE(COUNTROWS("correct_table"), Filter1, Filter2, etc) resolved this.

Was using the incorrect table thanks. 

View solution in original post

3 REPLIES 3
Leon12Smith
Frequent Visitor

CALCULATE(COUNTROWS("correct_table"), Filter1, Filter2, etc) resolved this.

Was using the incorrect table thanks. 

some_bih
Super User
Super User

Hi @Leon12Smith usually measure for count number of rows for some of table is 

Count rows=COUNTROWS ( table )

Adjust your table name

If you filter something and want to calculate "the rest" number of rows meaning non filtered rows you should use

Count rows rest =
VAR __rows_all=CALCULATE (

            COUNTROWS ( table ),
             ALL()             

)

VAR __rows_allselected=CALCULATE (

            COUNTROWS ( table ),
             ALLSELECTED()             

)

VAR __Result=__rows_all-__rows_allselected

RETURN __Result

 

Did I answer correctly?

Kudos appreciate / accept solution







Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






@some_bih, there is an additional condition "Written Amount > 0" mentioned.
Maybe something like this:

Rows = 
    CALCULATE(
        COUNTROWS(yout_table),
        Written Amount > 0
        )


@Leon12Smith Just an extended idea to suggested solution from @some_bih 

 

Regards

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors