Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello, I want to select certain cost codes in the cost code column to allow divison by another value. In a very simplified version I want to total the cost of the A codes and divide by the average area of A's. I need the formula to write this.
Cost Code | COST | Area (m2) |
A.1 | £1 | 10 |
A.2 | £2 | 10 |
A.3 | £3 | 10 |
A.4 | £4 | 10 |
B.1 | £5 | 20 |
B.2 | £6 | 20 |
B.3 | £7 | 20 |
Hi, @hayali01 , why not make a small transformation to the dataset, which saves a lot of trouble and brings about much clarity in authoring measures.
Avg Cost =
DIVIDE (
CALCULATE (
SUM ( 'Table'[COST] ),
FILTER ( ALL ( 'Table' ), 'Table'[Region] = MAX ( 'Table'[Region] ) )
),
CALCULATE (
AVERAGE ( 'Table'[Area (m2)] ),
FILTER ( ALL ( 'Table' ), 'Table'[Region] = MAX ( 'Table'[Region] ) )
)
)
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@hayali01 , Create a measure like
calculate(divide(sum(table[COST]), averageX(Table,table[Area (m2)])), filter( Table, left(Table[Cost Code],1) ="A"))
=VAR _c=LEFT(MAX('Table'[Cost Code]),FIND(".",MAX('Table'[Cost Code]),,99)-1) RETURN CALCULATE(DIVIDE(SUM('Table'[Cost]),AVERAGE('Table'[Area (m2)]),0),LEFT('Table'[Cost Code],FIND(".",'Table'[Cost Code],,99)-1)=_c)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
9 | |
7 | |
7 | |
6 |
User | Count |
---|---|
21 | |
11 | |
10 | |
9 | |
8 |