Forum Discussion
cookm01
1 year agoRegular Visitor
Creating two straight average lines on a bar chart
Hello, I am currently trying to create two straight average lines for a bar chart, to represent the averages for two years on the chart. The context (using dummy data): I have a bar chart whi...
- Anonymous1 year ago
Hi cookm01 ,
I create a table as you mentioned.
Then I create a measure and here is the DAX code.
Measure = VAR _currentYear = MAX ( 'Table'[Year ] ) RETURN CALCULATE ( AVERAGE ( 'Table'[% of income ] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Year ] = _currentYear ) )Finally you will see what you want.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
PhilipTreacy
1 year agoSuper User
Try these
2023 Avg = CALCULATE(AVERAGE('DataTable'[% of income ]), ALLEXCEPT('DataTable','DataTable'[% of income ]),'DataTable'[Year ] = 2023)
2024 Avg = CALCULATE(AVERAGE('DataTable'[% of income ]), ALLEXCEPT('DataTable','DataTable'[% of income ]),'DataTable'[Year ] = 2024)
regards
Phil