Forum Discussion

VinnieHuub's avatar
VinnieHuub
New Member
4 years ago
Solved

Dynamic Category based on selected date

Hi all,

 

I'm trying to create a new category column to an existing table, but it needs to be calculated based on a date selected by the end user.

 

F.e. we have this simple table called Customer:

 

CustnrTypeLogindateBalance
1Joint1/1/2020100
2Joint1/5/202010000
3Single1/6/2020400
4Minor1/9/20200
5Minor1/12/202050000
6Single1/2/202110
7Self Employed1/3/202130
8SME1/8/202140

 

A new column needs to be added based on the logindate and a selected date. If the logindate <= selecteddate, then Yes else No.
(A calculated column is a possibility, but then the dataset needs to be refreshed every time)

I tried the following:

 

create a date table, not related to any other table, to be used as a slicer

 

create a new table based on the existing adding the logincategory:

 

LoginCat =
VAR OnDate = date(2020,1,16)
RETURN
CALCULATETABLE(
ADDCOLUMNS(CUSTOMER, "LoginCat", if(CUSTOMER[Logindate] <= OnDate, "Yes", "No"))
)
 This works fine with the date hard-coded:


But when I change the variable to = selectedvalue(calendar[date]) it doesn't pick up the selected date.

Any idea?

 

Thank you.

 

Vincent

  • Hi, VinnieHuub 

     

    You can try the following methods.

    Date = CALENDAR(DATE(2020,1,1),DATE(2021,8,31))

    Measure:

    Measure = 
    IF (
        MAX ( 'Date'[Date] ) >= SELECTEDVALUE ( 'Customer'[Logindate] ),
        "Yes",
        "No"
    )

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

2 Replies