Forum Discussion
SWITCH OR IF STATEMENT for PY SHIPPED AMOUNT
- Anonymous7 years ago
HI lordsriram,
If you mean a measure contains two calculate logic based on 'today' function, you can try to use below measure formula:
Dyanmic Measure = VAR currDate = MAX ( Invoice[INVOICE DATE] ) RETURN IF ( YEAR ( currDate ) = YEAR ( TODAY () ), CALCULATE ( SUM ( 'SALES'[SHIPPED_AMOUNT] ), FILTER ( ALLSELECTED ( Sales ), [INVOICE_DATE] >= DATE ( YEAR ( TODAY () ) - 1, 1, 1 ) && [INVOICE_DATE] <= DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) ) ) ), CALCULATE ( SUM ( 'Sales'[SHIPPED_AMOUNT] ), FILTER ( ALLSELECTED ( 'Sales' ), YEAR ( [INVOICE_DATE] ) = YEAR ( currDate ) - 1 ) ) )
Regards,
Xiaoxin Sheng
Attached link has the file with the sample data
I am trying to get the total of shipped amount for each year and for the current year - I want the Previous year sales to be only for the dates till current date. For the rest of the years, i want to use the whole year for calculation. I want this to be in PY Shipped amount field and was trying to change the calculation display based on the year from invoice date table. I can do this in 2 different measures but the display to the user is a bit confusing.
Thanks
Sriram
- Anonymous7 years agoNot applicable
HI lordsriram,
If you mean a measure contains two calculate logic based on 'today' function, you can try to use below measure formula:
Dyanmic Measure = VAR currDate = MAX ( Invoice[INVOICE DATE] ) RETURN IF ( YEAR ( currDate ) = YEAR ( TODAY () ), CALCULATE ( SUM ( 'SALES'[SHIPPED_AMOUNT] ), FILTER ( ALLSELECTED ( Sales ), [INVOICE_DATE] >= DATE ( YEAR ( TODAY () ) - 1, 1, 1 ) && [INVOICE_DATE] <= DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) ) ) ), CALCULATE ( SUM ( 'Sales'[SHIPPED_AMOUNT] ), FILTER ( ALLSELECTED ( 'Sales' ), YEAR ( [INVOICE_DATE] ) = YEAR ( currDate ) - 1 ) ) )
Regards,
Xiaoxin Sheng