Forum Discussion
netanel
4 years agoPost Prodigy
Replace SELECTEDVALUE to something else
Hi All! i have this Dax: Gross USD = IF ( SELECTEDVALUE( 'db 2021'[Source]) = "Amazon", CALCULATE ( DIVIDE ( ( SUM ( 'DB 2021'[Gross USD] ) + SUM ( 'DB 2021'[Fee USD] ) ), COUNTROWS ( 'D...
- 4 years ago
Like Samarth said you should get the column as a suggestion. Are you using a measure now? If so you here is a completely new approach to this:
CALCULATE (DIVIDE (( SUM ( 'DB 2021'[Gross USD] ) + SUM ( 'DB 2021'[Fee USD] ) ),COUNTROWS ( 'Date' )),KEEPFILTERS ( 'Date'[Date] < TODAY () ),filter('db 2021','db 2021'[Source] = "Amazon"))+CALCULATE (DIVIDE ( SUM ( 'DB 2021'[Gross USD] ), COUNTROWS ( 'Date' ) ),KEEPFILTERS ( 'Date'[Date] < TODAY () ),filter('db 2021','db 2021'[Source] <> "Amazon"))The logic here is to use one calculate logic when customer is Amazon (include the fee there) and other when it is not.
netanel
4 years agoPost Prodigy
ValtteriN
4 years agoCommunity Champion
Just to clarify is the DAX you use a measure or a column?
- netanel4 years agoPost Prodigy
Sorry friends,
I was thinking in the wrong direction and a bit complicated it.
I went backwards and the direction of ValtteriN is the right direction
The Gross formula works well so I'll just add the Fee to it whit +
The problem is I only need the Fee when the Source is "Amazon"
So that's what I've put together
The second formula gets Blank
Why?1.
Gross USD =CALCULATE(DIVIDE( SUM( 'DB 2021'[Gross USD] ), COUNTROWS( 'Date' ) ),keepfilters( 'Date'[Date] < TODAY()))2. Measure ValtteriNAmazone Fee = IF (SELECTEDVALUE('DB 2021'[Source]) <> "Amazon", BLANK (), SELECTEDVALUE('DB 2021'[Fee]))If I connect the two formulas I get nothing
Because the second formula brings me Blank