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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

DAX Measure Suggestion

Hi,

I am trying to build a DAX Measure for Count of number of companies has been created after the first invoice 

 

We have invoice creation date(Invoice_Create Date)column and company established date(Company_Create_Date) columns, we just need to check that there is no invoice with this company id(Company ID)  on this specific Country Code(Company Code) prior to the company  established date.

I tried this measure

Num of invoices created before company established  =

var allcompanies = VALUES([Company ID])

var Company_established_date_greater_than_invoice_created_date = CALCULATETABLE(Company ID]),

FILTER (

Table name(),

Table name[Company_Create_Date] > Table name[Invoice_Create_date] )

)

return

COUNTROWS(Except(allCompanies,Company_established_date_greater_than_invoice_created_date)).

How can i relate the Country code with Company ID?

 

11 REPLIES 11
tamerj1
Super User
Super User

Hi @Anonymous 
Please try

Num of invoices created before company established =
SUMX (
    SUMMARIZE ( 'Table', 'Table'[Company ID], 'Table'[Country Code] ),
    COUNTROWS (
        FILTER (
            CALCULATETABLE ( 'Table' ),
            'Table'[Company_Create_Date] > 'Table'[Invoice_Create_date]
        )
    )
)
Num of companies created after invoice creation =
SUMX (
    SUMMARIZE ( 'Table', 'Table'[Company ID], 'Table'[Country Code] ),
    IF (
        NOT ISEMPTY (
            FILTER (
                CALCULATETABLE ( 'Table' ),
                'Table'[Company_Create_Date] > 'Table'[Invoice_Create_date]
            )
        ),
        1
    )
)
Anonymous
Not applicable

Thank you @tamerj1 , i will check these two measures

Anonymous
Not applicable

I need to check both Num of Invoices and num of Companies as well, Primarily i am trying to achieve num of companies/vendors

amitchandak
Super User
Super User

@Anonymous ,

 

Assume they are from same table. try this measure

 

Countx(filter(Summarize(Table, Table[Company], "_1", Min(Table[Invoice_Creation Date]), "_2", Min(Table[Company_Create_Date]) ), [_2] >[_1]), [Company])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

I tried this measure,but not showing any Visual

Anonymous
Not applicable

Hi Amit,
Thank You for the response,
But How the company ID is relates to Country Code?

 

Anonymous
Not applicable

Company Id, Country ID, COmpany Est Date and Invoice created date are belongs to same table.

@Anonymous 
Does the Country ID refer to the company or to the invoice?

Anonymous
Not applicable

yes @tamerj1 i need to check, if there is any invoices created with the company id on a specific country code before the company established date.

@Anonymous 
Ok. Are you trying to calculate the number of invoices or the number of companies? I'm asking this because the title contradicts with your dax code attempt.

Anonymous
Not applicable

I need both num of invoices and number of companies info but primarily i am working on Number of companies that has been created after the first invoice out of total no of the companies that has been created

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.