RockandGrohl
Well-known Member
- Joined
- Aug 1, 2018
- Messages
- 810
- Office Version
- 365
- Platform
- Windows
Hi, bit of a confusing one here but I'll give it my best.
Our Database of Projects has between 1-5 Stages per project, and each stage has multiple rows which are the individual cost components of the project.
Some projects in the database have stage 1, 3, 4, some have stages 3 and 4 only, some have 1 and 5 only, you get the drift..
What I'm trying to do is create a bar chart where I can use a slicer to select, say, stages 1, 3 and 4 and it shows three bars with the total cost for each, which is a sum only of projects that have stages 1, 3 and 4 in the database.
ChatGPT seems to think this is perfectly possible but the end result is that the chart it shows me doesn't appear to be summing up the costs only for projects that have all the selected gateways, see below:
Step 1: Create a Measure to Verify Valid Projects
Step 2: Create a Measure for Filtered Costs
This just results in a chart which doesn't seem to only count projects that fulfill all of the Stage selection criteria.
Our Database of Projects has between 1-5 Stages per project, and each stage has multiple rows which are the individual cost components of the project.
Some projects in the database have stage 1, 3, 4, some have stages 3 and 4 only, some have 1 and 5 only, you get the drift..
What I'm trying to do is create a bar chart where I can use a slicer to select, say, stages 1, 3 and 4 and it shows three bars with the total cost for each, which is a sum only of projects that have stages 1, 3 and 4 in the database.
ChatGPT seems to think this is perfectly possible but the end result is that the chart it shows me doesn't appear to be summing up the costs only for projects that have all the selected gateways, see below:
Step 1: Create a Measure to Verify Valid Projects
Power Query:
ValidProjects =
VAR SelectedStages = VALUES('Database'[Stage])
VAR ProjectStages =
CALCULATETABLE(
VALUES('Database'[Stage]),
ALLEXCEPT('Database', 'Database'[Project ID])
)
RETURN
IF(
COUNTROWS(SelectedStages) = COUNTROWS(INTERSECT(SelectedStages, ProjectStages)),
1,
0
)
Step 2: Create a Measure for Filtered Costs
Power Query:
FilteredCost =CALCULATE( SUM('Database'[Cost (Original)]), FILTER( 'Database', [ValidProjects] = 1 ))
Step 3: Build the Bar Chart
- Add a Bar Chart to your report.
- Set up the fields as follows:
- Y-axis: Stage (from your Database table).
- X-axis: FilteredCost (the measure we just created).
- Add a Slicer:
- Drag Stage to the slicer visual.
- Enable multi-select mode in the slicer.
This just results in a chart which doesn't seem to only count projects that fulfill all of the Stage selection criteria.