Forum Discussion
Bansi008
2 years agoHelper III
Custom column using contidition statement.
Hi, I am currently working on the validation project. I have the following 2 sample modules in the PowerBI dashboard. In Table 1, column S_Contrib_R is a custom column created using the formula belo...
- 2 years ago
Hi Bansi008 .
Pleas try this:
formula = VAR S_Contrib_R = CALCULATE ( SUM ( 'Table 2'[CONTRIB_Master] ), FILTER ( 'Table 2', 'Table 2'[Unique Key] = EARLIER ( 'Table 1'[Unique Key] ) ) ) VAR CONTRIB_R_MTD = CALCULATE ( SUM ( 'Table 2'[CONTRIB_R_MTD] ), FILTER ( 'Table 2', 'Table 2'[Unique Key] = EARLIER ( 'Table 1'[Unique Key] ) ) ) RETURN IF ( 'Table 1'[Purchase] = "P", CONTRIB_R_MTD, COALESCE ( CONTRIB_R_MTD, S_Contrib_R ) )If this is not what you're looking for, please post a workable sample data (not an image) and your expected result using the same sample data.
danextian
2 years agoSuper User
Hi Bansi008 .
Pleas try this:
formula =
VAR S_Contrib_R =
CALCULATE (
SUM ( 'Table 2'[CONTRIB_Master] ),
FILTER ( 'Table 2', 'Table 2'[Unique Key] = EARLIER ( 'Table 1'[Unique Key] ) )
)
VAR CONTRIB_R_MTD =
CALCULATE (
SUM ( 'Table 2'[CONTRIB_R_MTD] ),
FILTER ( 'Table 2', 'Table 2'[Unique Key] = EARLIER ( 'Table 1'[Unique Key] ) )
)
RETURN
IF (
'Table 1'[Purchase] = "P",
CONTRIB_R_MTD,
COALESCE ( CONTRIB_R_MTD, S_Contrib_R )
)
If this is not what you're looking for, please post a workable sample data (not an image) and your expected result using the same sample data.
- Bansi0082 years agoHelper III
Thanks, this perfectly works as expected.