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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors