I'm really not sure what structure of DAX to use for this problem. I have 2 tables, one with the Projects and another table with all of the risks for the projects, so it is a one to many relationship.
I want to do a check of ALL the risks in the corresponding Risks table for each project to see if any are red.
If so, the number of red risks should be counted, displayed in the Projects[RedRisk] column with the count number and the background color changed to red. Can use conditional formating to change the BG color.
So putting it out there to see if someone has no doubt already done this and can share their method?
I've tried lots things but can't not quite sure how to pull it off.
Have included an example of the tables to illustrate.
Solved! Go to Solution.
Thanks - that works! Much appreciated. I knew there must be a way of doing this, but it's alwasy easy if you know how. Many thanks to both for your help.
Just a quick footnote on this - the 'accepted solution' filters the records based on IDs, i.e .it will only return records that have red risks, so it removes all other records instead of including them but giving them a value of zero.
Hi, @ercwebdev , you might want to use such a measure in a table/matrix visualization in Power BI,
RedRisk = COUNTROWS(FILTER(Risks, Risks[RiskColour]="Red"))
Hi there @CNENFRNL , thanks for that - pretty decent stab at it! What that is doing is looking through all the rows and counting the red (a total of 29) and doing it for every row and putting the value in. Just need it now to filter on ProjectID = ProjectID, but no idea how to do that with DAX?
Hi, @ercwebdev , the most sophisticated part of DAX is filter propagation along with relationships among tables.
As to your example, if 'Project Data'[ProjectID] is dragged and dropped in a table/matrix viz, Risks[ProjectID] is at first hand automatically filtered by 'Project Data'[ProjectID] given that there exists such a relationship, 'Project Data'[ProjectID] 1:M Risks[ProjectID].
Better attach a mockup so that it's way much easier to get your issue done.
Ok, have made a quick mockup and zipped (.pbix and Excel) if you want to download and try having a play:
I've done some work on this and managed to get something that will suffice and do the job. Thought I would share it with the community.
Created a new Table with the following:
MyRedRiskTbl = FILTER( Risks, Risks[RiskColour]="Red" )
This brings the Projects in that have a red. It seems to do a Distinct and doesn't duplicate them.
Then added a new column in the Project Data to look up and check if there is a corresponding value in the virtual table:
RedRiskCheckTwo = LOOKUPVALUE( MyRedRiskTbl[RiskColour],----- Result Column Name MyRedRiskTbl[Project ID],--- Search column 'Project Data'[Project ID] ----- Search Value , Blank()--- Not Match with condition returns Blank )
This will then either insert 'Red' or leave it blank. I can then do some color formatting based on this.
Here is how it looks:
Check out new user group experience and if you are a leader please create your group!
Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.
Click here to read more about the July 2021 Updates
Did you know that you can visit the Power Query Forum in Power BI and now Power Apps