Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi,
So I am using a Direct Query to bring in some inspection information for catch basins. Basically I have two tables; one with all of our catchbasins (id of each one = FACILITYID) and another with inspection information. My query joins the two tables on FACILITYID and then shows all of the catchbasins along with the most recent inspection date (INSP_DATE). If there is no inspection done on it yet, the INSP_DATE is null.
SELECT works.SSCATCHBASIN.FACILITYID, Max(works.INSPECTIONS_CATCHBASIN_INSPECTION.INSP_DATE) AS MaxOfINSP_DATE, works.SSCATCHBASIN.DEPOTAREA
FROM works.SSCATCHBASIN LEFT JOIN works.INSPECTIONS_CATCHBASIN_INSPECTION ON works.SSCATCHBASIN.FACILITYID = works.INSPECTIONS_CATCHBASIN_INSPECTION.FACILITYID
GROUP BY works.SSCATCHBASIN.FACILITYID, works.SSCATCHBASIN.LIFECYCLESTATUS, works.SSCATCHBASIN.DEPOTAREA
HAVING (((works.SSCATCHBASIN.LIFECYCLESTATUS)='ASSUMED' Or (works.SSCATCHBASIN.LIFECYCLESTATUS)='ISSUED FOR CONSTRUCTION' Or (works.SSCATCHBASIN.LIFECYCLESTATUS)='MAINTENANCE'));
So the end table is basically all catchbasins with the most recent inspection, with a NULL date for those with no inspection.
One problem I am having is that I cannot create a date hierarchy of MaxOfINSP_DATE field. It's showing up as a valid Date/Time field in the Power Query Editor. From what I've read this might be an issue with Direct Query, but I'm not totally sure.
I'd like to do this since I need to create a % inspected visual and I figure this would be the easiest way to do it. So for 2022, all catchbasins inspected in either 2022 or 2021 would be considered "inspected" and everything else (including NULL date) would be considered "uninspected".
Hopefully that makes sense.
I am a total newbie to Power BI, so please be gentle with me so perhaps my logic to this is totally wrong. 🙂
Solved! Go to Solution.
OMG! I finally go this to work. So I added 3 measures; 1 for CatchBasin count (CB_Count), 1 for the Inspection count (INSP_Count) and 1 to calculate the % completed (PercentComplete).
This only took me about 3 days!! LOL
OMG! I finally go this to work. So I added 3 measures; 1 for CatchBasin count (CB_Count), 1 for the Inspection count (INSP_Count) and 1 to calculate the % completed (PercentComplete).
This only took me about 3 days!! LOL