Forum Discussion
Dynamic Date IF Statement
Hi,
I'm trying to do a simple IF Statment but it doesn't seem to work; I'm trying to created a calculate column to use as a customer filter.
I'm looking at 3 Columns as listed below:
- (Measure) Date_Selected = CALCULATE(MAX('DATE'[Date]),ALLSELECTED('DATE'))
- dwh InventoryTenancy'[Start] = Colum from data set
- dwh InventoryTenancy'[End] = Colum from data set
In the below screen shot the highlighed "Exclude" should be "Include".
Any help is always appricated.
Thanks
Dobby Libr3
Hi Anonymous
Do you check my answers above?
these are all measures instead of columns
max selected = MAX('calendar'[Date]) Measure = IF([max selected]>MAX([start])&&[max selected]<=MAX([end]),"Include","exclude")Best Regards
Maggie
13 Replies
- nandukrishnavsCommunity Champion
Hi Anonymous ,
Slicers cannot be used in calculated columns. Instead, you can use measure.
Date_Selected = CALCULATE(MAX('DATE'[Date]),ALLSELECTED('DATE'))ReportFilter = VAR selectedDate = 'Date'[Date_Selected] VAR result = CALCULATE ( IF ( selectedDate > SELECTEDVALUE ( Inventory[Start] ) && selectedDate <= SELECTEDVALUE ( Inventory[End] ), "Include", "Exclude" ) ) RETURN resultsnapshot
If required you apply a visual level filter.
Regards,
Nandu Krishna
- AnonymousNot applicable
Hi nandukrishnavs ,
Unfortantly this bough back the same results I got where it seems to not be applying the logic.
Thanks
Rob
- FrankATCommunity Champion
Hi Anonymous,
are your Start and End date true calendar dates? If they are text it doesn't work!
Regards FrankAT
- FrankATCommunity Champion
Hi,
try the following measure:
Report Filter = IF ( MIN ( 'dwh InventoryTenancy'[Start] ) > CALCULATE ( MIN ( 'Date'[Date] ), ALLSELECTED ( 'Date' ) ) && MIN ( 'dwh InventoryTenancy'[End] ) <= CALCULATE ( MAX ( 'Date'[Date] ), ALLSELECTED ( 'Date' ) ), "Include", "Exclude" )Regards FrankAT
- AnonymousNot applicable
Hi FrankAT,
thanks for your input, I currently getting the insufficent memory error, ( I have 32gb RAM and am connecting to a datawarehouse) so I don't think its really a memory issue.
- v-juanli-msftCommunity Support
Hi Anonymous
Is this problem sloved?If it is sloved, could you kindly accept it as a solution to close this case and help the other members find it more quickly?If not, please feel free to let me know.Best RegardsMaggie- AnonymousNot applicable
Hi Maggie,
Still not resolved, I have tired out all the Measures in the chat and also looked at the model, I can't figure out why its not picking up, Also my data set has less than 20,000 line and the refresh on visuals takes far too long for the simple calculations.
there is a picture of my model, date table is not connected...
- v-juanli-msftCommunity Support
Hi Anonymous
Do you check my answers above?
these are all measures instead of columns
max selected = MAX('calendar'[Date]) Measure = IF([max selected]>MAX([start])&&[max selected]<=MAX([end]),"Include","exclude")Best Regards
Maggie