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

Logical operations between two tables

Hi! I have 2 tables:

Table A: document | start date | end date | Yearmonth

Table B: document | date | Yearmonth

 

Table A had duplicates so I created a referenced table to table A grouping by document, min(start), max(end), this way I now have 1 document per row, and I created a relation between this and B on document.

 

Not every field in B has a document in A.

 

I need to know how many of the records in B have a date between A[start date] and A[start date].

 

I tryied a lot of things but the simplest of all I can't directly compare values using IF.

Any ideas?

Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Ok, I solved like this:

New column-> Time_ok = IF ( 'Table B'[date]< RELATED ( 'Table A'[max_date] ) ) ;1;0 )

 

And new measure to get the percentages:

 

New Measure -> % tiempo = DIVIDE(SUM('Table B'[Time_ok]);count('Table B'[document])) 

 

It seems to work, buy I'm new to Power BI so I'd like to know if there is a better solution.

Thank you!

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Ok, I solved like this:

New column-> Time_ok = IF ( 'Table B'[date]< RELATED ( 'Table A'[max_date] ) ) ;1;0 )

 

And new measure to get the percentages:

 

New Measure -> % tiempo = DIVIDE(SUM('Table B'[Time_ok]);count('Table B'[document])) 

 

It seems to work, buy I'm new to Power BI so I'd like to know if there is a better solution.

Thank you!

@Anonymous,

 

You may also try SUMX Function to add a measure directly.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Great! but I think will lost readeability if I continue to nest functions (because I'm new and want to understand my code in 2 weeks, when I advance furter I'll begin using your method), thanks!

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