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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
knasveschuk
Helper I
Helper I

COUNTROWS in table use other table values

I would like to count rows in table2 using table1 for conditional filtering

Table1 is calculated: typesTime = DISTINCT('timeStatus'[type])

table1

typesTime
type
overtime
sick_pay
sick_no_pay
holiday
personal
military
jury
bereavement
normal

 

table2

TimeStatus  
datetypename
6/20/2020overtimefred
6/19/2020sick_payjohn
6/20/2020normalmary
6/20/2020normalmary
6/20/2020normalfred
6/20/2020normaljohn
6/20/2020normaljohn

 

I would like to count number of each "type" in table2 using table1 to get desired output below, is this possible with DAX?

desired output

overtime60
sick_pay345
sick_no_pay3
holiday512
personal201
military17
jury45
bereavement245
normal45620
1 ACCEPTED SOLUTION
knasveschuk
Helper I
Helper I

I found another way around this I did not know it existed. I'm new to BI.

View solution in original post

4 REPLIES 4
knasveschuk
Helper I
Helper I

I found another way around this I did not know it existed. I'm new to BI.

v-lili6-msft
Community Support
Community Support

hi  @knasveschuk 

For your case, the simple way is use this formula to create a table1 instead of yours

 

Table 1 = SUMMARIZE(TimeStatus,TimeStatus[type],"amount",CALCULATE(COUNTROWS(TimeStatus)))

 

 

another way is create a relationship between table 1 and table2, then in table 1 create a new column as this

 

Amount = CALCULATE(COUNTROWS('TimeStatus'))

 

 

and here is sample pbix file, please try it.

 

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.


@amitchandak wrote:

@knasveschuk, not very clear to me . see if this can help

https://docs.microsoft.com/en-us/dax/treatas-function

https://www.sqlbi.com/articles/propagate-filters-using-treatas-in-dax/


I think I can do this another way, being new to BI I stumbled upon a solution without calculating anything

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.