Forum Discussion
Allocating Cost Formula
- 5 years ago
is this waht you want?
Column = if('Table'[Location]="Central",'Table'[Cost],maxx(FILTER('Table','Table'[Project# ]=EARLIER('Table'[Project# ])&&'Table'[Location]="Central"),'Table'[Cost]/CALCULATE(COUNTROWS('Table'),'Table'[Location]<>"Central",ALLEXCEPT('Table','Table'[Project# ])))) - 5 years ago
Hi dw700d ,
What ryan_mayu created is a custom column using M language in Power Query Editor.
If you wnat to create a column or measure using DAX, try this:
Column = VAR Cost_ = CALCULATE ( SUM ( 'Table'[Cost] ), ALLEXCEPT ( 'Table', 'Table'[Project#] ) ) VAR LocationCount = CALCULATE ( COUNT ( 'Table'[Location] ), FILTER ( ALLEXCEPT ( 'Table', 'Table'[Project#] ), 'Table'[Location] <> "Central" ) ) RETURN IF ( 'Table'[Location] = "Central", [Cost], DIVIDE ( Cost_, LocationCount ) )Measure = VAR Cost_ = CALCULATE ( SUM ( 'Table'[Cost] ), ALLEXCEPT ( 'Table', 'Table'[Project#] ) ) VAR LocationCount = CALCULATE ( COUNT ( 'Table'[Location] ), FILTER ( ALLEXCEPT ( 'Table', 'Table'[Project#] ), 'Table'[Location] <> "Central" ) ) RETURN IF ( MAX( 'Table'[Location] ) = "Central", Cost_, DIVIDE ( Cost_, LocationCount ) )Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
is this waht you want?
Column = if('Table'[Location]="Central",'Table'[Cost],maxx(FILTER('Table','Table'[Project# ]=EARLIER('Table'[Project# ])&&'Table'[Location]="Central"),'Table'[Cost]/CALCULATE(COUNTROWS('Table'),'Table'[Location]<>"Central",ALLEXCEPT('Table','Table'[Project# ]))))
- dw700d5 years agoPost Patron
Thanks Ryan I cant get past the if statement. It doesnt recognize my table or columns. Could there be something missing from the measure?
- Icey5 years agoCommunity Support
Hi dw700d ,
What ryan_mayu created is a custom column using M language in Power Query Editor.
If you wnat to create a column or measure using DAX, try this:
Column = VAR Cost_ = CALCULATE ( SUM ( 'Table'[Cost] ), ALLEXCEPT ( 'Table', 'Table'[Project#] ) ) VAR LocationCount = CALCULATE ( COUNT ( 'Table'[Location] ), FILTER ( ALLEXCEPT ( 'Table', 'Table'[Project#] ), 'Table'[Location] <> "Central" ) ) RETURN IF ( 'Table'[Location] = "Central", [Cost], DIVIDE ( Cost_, LocationCount ) )Measure = VAR Cost_ = CALCULATE ( SUM ( 'Table'[Cost] ), ALLEXCEPT ( 'Table', 'Table'[Project#] ) ) VAR LocationCount = CALCULATE ( COUNT ( 'Table'[Location] ), FILTER ( ALLEXCEPT ( 'Table', 'Table'[Project#] ), 'Table'[Location] <> "Central" ) ) RETURN IF ( MAX( 'Table'[Location] ) = "Central", Cost_, DIVIDE ( Cost_, LocationCount ) )Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.