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.
ValtteriN
4 years agoCommunity Champion
netanel
So now that I know it is a column a simple IF logic should be fine. As you can see in my example above, if you are creating a calculated column there is no need for MAX/SELECTEDVALUE. e.g.
IF (
'db 2021'[Source] = "Amazon",
CALCULATE (
DIVIDE (
( SUM ( 'DB 2021'[Gross USD] ) + SUM ( 'DB 2021'[Fee USD] ) ),
COUNTROWS ( 'Date' )
),
KEEPFILTERS ( 'Date'[Date] < TODAY () )
),
CALCULATE (
DIVIDE ( SUM ( 'DB 2021'[Gross USD] ), COUNTROWS ( 'Date' ) ),
KEEPFILTERS ( 'Date'[Date] < TODAY () )))
- Samarth_184 years agoCommunity Champion
netanel just remove source from this line 'db 2021'[Source] = "Amazon", and click on ctrl+space bar it will suggest column names then select source column from there. It will work.
- netanel4 years agoPost Prodigy
- ValtteriN4 years agoCommunity Champion
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.