I was kindly helped here: Power BI, DAX, Many-to-one and relational tables
to produce a measure column based on this data:
Builds = DATATABLE( "Build", STRING, "App", STRING, { { "Build1", "App1" }, { "Build1", "AppNotInApps1" }, { "Build1", "App2" }, { "Build1", "App9" }, { "Build2", "App3" }, { "Build2", "AppNotInApps2" }, { "Build3", "App1" }, { "Build3", "App5" }, { "Build3", "App8" }, { "Build3", "App9" }, { "Build3", "AppNotInApps3" } } ) Apps = DATATABLE( "App", STRING, "Status", STRING, { { "App1", "UAT" }, { "App2", "Complete" }, { "App9", "New" }, { "App3", "Complete" }, { "App5", "UAT" }, { "App8", "Complete" } } )
Many Builds have one Apps, joined on Builds.App = Apps.App.
The measure column (called ‘incomplete’) was this little beauty:
incomplete = IF( HASONEVALUE( Builds[Build] ), VAR CurrentBuild = SELECTEDVALUE( Builds[Build] ) VAR CurrentApp = SELECTEDVALUE( Apps[App] ) VAR Result = COUNTROWS( FILTER( ALLNOBLANKROW( Builds ), Builds[Build] = CurrentBuild && RELATED( Apps[Status] ) <> "Complete" && NOT ISBLANK( RELATED( Apps[Status] ) ) ) ) + 0 RETURN IF( NOT ISBLANK( SELECTEDVALUE( Apps[Status] ) ), Result ) )
What i want to do now is have two cards in my BI view.
Card one (a measure?) – Count the DISTINCT number of Builds.Build that has an ‘incomplete’ count of 0.
Card two (a measure?) – Count the DISTINCT number of Builds.Build that has an ‘incomplete’ count that is NOT equal to 0.
Card three – card one measure as a percentage of (card one measure plus card 2 measure)
I have filters (slicers) on my page so i need the measure to be dynamic.
I’ve tried this for card 1, but it doesn’t give me the correct value?
comp = CALCULATE( DISTINCTCOUNT(Builds[Build]), FILTER(ALLSELECTED(Build), [incomplete] = 0))
And of course this for card 2:
comp = CALCULATE( DISTINCTCOUNT(Builds[Build]), FILTER(ALLSELECTED(Build), [incomplete] <> 0))
Is there something I’m missing before i try my card 3?