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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
IghorFerreira
New Member

Count Rows From 2 Different Fact Tables Based in Date

Hello, everyone! It's my first post here, sorry if there's anything wrong in the request.

 

I need to count the total amount of preventive work orders executed by machine and date in one table, but only if it was scheduled in other table so I can get the % of scheduled and executed. Some of the preventives executed aren't scheduled, so these ones can't be counted. I've made some research and tried to work it out with 2 or 3 different methods, but none did worked properly. 

 

Here's some dummy data with the simplified structure of both tables and the expected result:

IghorFerreira_0-1741291582034.png

 

So far I haven't tryed doing it through Power Query, but I'll accept suggestion for that too.

 

1 ACCEPTED SOLUTION
gmsamborn
Super User
Super User

Hi @IghorFerreira 

 

Would the following measures help?

 

Scheduled = 
    CALCULATE(
        COUNTROWS( 'Schedule' ),
        'Schedule'[Data] IN VALUES( 'Date'[Date] )
    )


Completed = 
    CALCULATE(
        DISTINCTCOUNT( 'WorkOrders'[Machine] ),
        'WorkOrders'[Date] IN VALUES( 'Schedule'[Data] )
    )


Compliance % = 
    DIVIDE( 
        [Completed], 
        [Scheduled] 
    )

 

 

Let me know if you have any questions.

 



Proud to be a Super User!

daxformatter.com makes life EASIER!

View solution in original post

5 REPLIES 5
v-kpoloju-msft
Community Support
Community Support

Hi @IghorFerreira,


May i know has your issue been resolved? If the response provided by the Super user @gmsamborn, addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.

If yes, kindly accept the useful reply as a solution and give us Kudos. It would be appreciated.

Thank you for your understanding!

Hi @IghorFerreira,


I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.


Thank you.

Hi @IghorFerreira,


I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.


Thank you.

gmsamborn
Super User
Super User

Hi @IghorFerreira 

 

Would the following measures help?

 

Scheduled = 
    CALCULATE(
        COUNTROWS( 'Schedule' ),
        'Schedule'[Data] IN VALUES( 'Date'[Date] )
    )


Completed = 
    CALCULATE(
        DISTINCTCOUNT( 'WorkOrders'[Machine] ),
        'WorkOrders'[Date] IN VALUES( 'Schedule'[Data] )
    )


Compliance % = 
    DIVIDE( 
        [Completed], 
        [Scheduled] 
    )

 

 

Let me know if you have any questions.

 



Proud to be a Super User!

daxformatter.com makes life EASIER!
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.