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

Compare / Combine Data

Hello All,

 

I have 2 tables - one has a list of locations, the 2nd has a list of locations, date of inspections, and scores of those inspections (Two different types of inspections) for each location. There are also multiple scores for each location and I need to filter it to only show the most recent inspection.

 

Can someone help? I have been able to get this to work with single inspection types, but I cannot get it to work with multiple.

 

See the layout below:

 

Table1:

BuildingNameColumn

Buildng 1

Building 2

Building 3

Building 4

Building 5

Building 6

Building 7

Building 8

 

Table 2

BuildingNameColumn             AuditScorePercentage  1       Date1            AuditScorePercentage 2           Date2

Building 1                                                95.00%               3/23/2022                             -                                -

Building 1                                                    -                             -                                95.00%                    3/21/2022

Building 4                                                95.00%               3/15/2022                             -                                -

Building 4                                                    -                             -                                95.00%                    3/14/2022

Building 6                                                95.00%               3/08/2022                             -                                -

 

Desired Result

BuildingNameColumn             AuditScorePercentage  1       Date1          AuditScorePercentage 2           Date2

Building 1                                                95.00%               3/23/2022                     95.00%               3/21/2022

Building 2                                                    -                           -                                   -                           - 

Building 3                                                    -                           -                                   -                           - 

Building 4                                                95.00%               3/15/2022                     95.00%               3/14/2022

Building 5                                                    -                           -                                   -                           - 

Building 6                                                95.00%               3/08/2022                          -                           -

Building 7                                                    -                           -                                   -                           - 

Building 8                                                    -                           -                                   -                           - 

1 ACCEPTED SOLUTION

@datadmin-austin,

 

I revised the two measures below:

 

Audit Date 1 = 
IF ( MAX ( Table2[AuditScorePercentage1] ) <> BLANK (), MAX ( Table2[Date1] ) )
Audit Date 2 = 
IF (
    MAX ( Table2[AuditScorePercentage2] ) <> BLANK (),
    CALCULATE ( MAX ( Table2[Date1] ), Table2[AuditScorePercentage2] <> BLANK () )
)

 

DataInsights_0-1652195394479.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

8 REPLIES 8
DataInsights
Super User
Super User

@datadmin-austin,

 

Try this solution.

 

Data model:

 

DataInsights_0-1652132982369.png

 

Measures:

 

Audit Date 1 = MAX ( Table2[Date1] )
Audit Date 2 = MAX ( Table2[Date2] )
Audit Score Percentage 1 = MAX ( Table2[AuditScorePercentage1] )
Audit Score Percentage 2 = MAX ( Table2[AuditScorePercentage2] )

 

In the visual, use Table1[BuildingNameColumn] and enable "Show items with no data".

 

DataInsights_1-1652133064546.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@DataInsights Thank you for the assistance here! I made one mistake and this is where I am stuck - the dates are where I have the most issues:

 

Any ideas here?

 

Table 2

BuildingNameColumn             Date  1       AuditScorePercentage 1           AuditScorePercentage 2

Building 1                               3/23/2022               95.00%                                           -                  

Building 1                               3/21/2022                     -                                            95.00%                

Building 4                               3/15/2022                95.00%                                           -                

Building 4                               3/14/2022                     -                                            95.00%          

Building 6                               3/08/2022                95.00%                                           -        

 

Desired Result

BuildingNameColumn             AuditScorePercentage  1       Date1          AuditScorePercentage 2           Date2

Building 1                                                95.00%               3/23/2022                     95.00%               3/21/2022

Building 2                                                    -                           -                                   -                           - 

Building 3                                                    -                           -                                   -                           - 

Building 4                                                95.00%               3/15/2022                     95.00%               3/14/2022

Building 5                                                    -                           -                                   -                           - 

Building 6                                                95.00%               3/08/2022                          -                           -

Building 7                                                    -                           -                                   -                           - 

Building 8                                                    -                           -                                   -                           - 

@datadmin-austin,

 

I revised the two measures below:

 

Audit Date 1 = 
IF ( MAX ( Table2[AuditScorePercentage1] ) <> BLANK (), MAX ( Table2[Date1] ) )
Audit Date 2 = 
IF (
    MAX ( Table2[AuditScorePercentage2] ) <> BLANK (),
    CALCULATE ( MAX ( Table2[Date1] ), Table2[AuditScorePercentage2] <> BLANK () )
)

 

DataInsights_0-1652195394479.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@DataInsights Thank you very much! That all worked very well. I have one last question, what is the best way to handle changes in the "Date"?

 

For example, if I only want it to show audits with dates from Quarter 1 or if I want it to show inspecitons from the last 180 days. I added filters to each date which works, but some data is still missing when using filters. Thank you!

@datadmin-austin,

 

Glad to hear that worked. I recommend creating a date table and using fields from the date table in a slicer or filter. Create a relationship between the date table and Table2. This will result in a star schema.

 

DataInsights_0-1652306667683.png

 

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/ 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@DataInsights Thank you! Do you have a sample date table? 

 

I believe I got this to work, but I have not finished testing, see my table here and feel free to judge how it looks or if there are more fields that should be added to further filter dates.

datadminaustin_0-1652361764124.png

 

Thank you! 

 

@datadmin-austin,

 

See the link below. You may not need all these columns, so I would focus on what you want from your data model, and create those columns.

 

https://www.sqlbi.com/articles/reference-date-table-in-dax-and-power-bi/ 

 

Here's a link to a date table in Power Query:

 

https://radacad.com/all-in-one-script-to-create-date-dimension-in-power-bi-using-power-query 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@DataInsights Thank you very much for your time! Everything is working and I will use these links as reference.

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.