Forum Discussion
Issue with measure
- 3 years ago
I don't know what is going on with the calculated column, but you can get the daily figures by amending your calculation item to be
VAR numDaysBefore = SELECTEDVALUE ( 'Days Before Today'[Days Before Today] ) VAR numDaysAfter = SELECTEDVALUE ( 'Days After Today'[Days After Today] ) VAR baseDate = TODAY () VAR startDate = baseDate - numDaysBefore VAR endDate = baseDate + numDaysAfter VAR datesToUse = DATESBETWEEN ( DateTable[Date], startDate, endDate ) VAR selectedDate = SELECTEDVALUE( DateTable[Date]) RETURN IF( selectedDate IN datesToUse, CALCULATE( SELECTEDMEASURE(), KEEPFILTERS( datesToUse ) ) )
Hi John,
I have tried my best to replicate the file.
So, I cannot replicate the issue I have with the calculated column in the original file - which I cannot share as it is confidential. It looks the same, format is number, no blanks, but PowerBI will not allow me to do any aggregation with it. When I put this calculated column in a table, instead of having the sum as per specified summarization, I get discreet numbers... I don't understand what is going on. If you have any hints about what I can check, it would be much appreciated!
Calculated Column:
Total Amount (kg) =
However, even with the mock file, I can't get what I want which is actually what you suggested to me on another post (Solved: Re: Use What-If parameter for selecting a date int... - Microsoft Power BI Community). I wanted to be able to let the users filter for dates through the use of parameter slicers (Days Before Today/ Days After Today), as you taught me . I have tried to apply the calculation group, but it does not work... the measure calculates for every date, so I cannot filter out what's = 0. What am I doing wrong?
File is on https://we.tl/t-tjWRmXRCAU
Thanks a lot!
Kind regards
Valeria
I don't know what is going on with the calculated column, but you can get the daily figures by amending your calculation item to be
VAR numDaysBefore =
SELECTEDVALUE ( 'Days Before Today'[Days Before Today] )
VAR numDaysAfter =
SELECTEDVALUE ( 'Days After Today'[Days After Today] )
VAR baseDate =
TODAY ()
VAR startDate = baseDate - numDaysBefore
VAR endDate = baseDate + numDaysAfter
VAR datesToUse = DATESBETWEEN (
DateTable[Date],
startDate,
endDate
)
VAR selectedDate = SELECTEDVALUE( DateTable[Date])
RETURN
IF(
selectedDate IN datesToUse,
CALCULATE(
SELECTEDMEASURE(),
KEEPFILTERS( datesToUse )
)
)