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
Anonymous
Not applicable

Incorrect no. of POs thru calculate

Dear All,

I am new to Power BI/DAX world. I want to add a column in table named Test PR POS ONLY. The name of column is Count of POs. My DAX command is given below: (which is not giving correct no.)

 

Count of POS =

VAR TotalRowsTestprTable = COUNTROWS('test pr')

RETURN CALCULATE(TotalRowsTestprTable, FILTER('test pr', 'test pr'[PO Date].[Date]='test pr POS ONLY'[PR Date].[Date]))

1. Test Pr table is as below

PR No.PR DatePO DatePO No
1001/01/202001/01/2020110
2002/01/202005/01/2020120
3003/01/202006/01/2020130
4004/01/202007/01/2020140
5005/01/202008/01/2020150
6006/01/202011/01/2020160
7007/01/202007/01/2020170
8008/01/202011/01/2020180
9009/01/202015/02/2020190

 

2. My Test PR POs ONLY table is as below

PR DateCount of POs
01/01/202020
02/01/202020
03/01/202020
04/01/202020
05/01/202020
06/01/202020
07/01/202020
08/01/202020
09/01/202020

 

3. The above no. 20 (which is wrong) is calculated as a result of my DAX command

4. i have 1 to many relation between Test PR POS ONLY table and Test PR tables

Please help where am i making the mistake. Thanks ifti1970@gmail.com

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous ,

New Table =summarize('Test Pr','Test Pr'[PR Date],"Count of POs", Count('Test Pr'[PO No]))

 

New column in the table
Count of POs = countrows(related('Test Pr'[PO No])) //only when it is 1 to M-HIPOTPol
or
Count of POs = countx(filter('Test Pr', 'Test Pr'[PR Date] = 'Test PR POs'[PR Date]),'Test Pr'[PO No])

Greg_Deckler
Super User
Super User

@Anonymous I believe all you should need is:

 

COUNTROWS(RELATEDTABLE('Table1'))


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors