Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
MiKeZZa
Post Patron
Post Patron

Hide lines when date from picker is greater than the fact

Hi amazing guys (and girls) that are helping people.... I'm a fanatic PowerBI user but I do have a problem that I can't fix now.

 

I have a dataset like this:

 

3.png

 

So what you see is that 1 cliënt can be on 1 day with more than 1 record, because of the costcenter (record 1+2) and the column 'lenght in days' gives the total length in days instead of the lenght at the specific day.

 

We are now looking for something like this:

 

1.png

 

So it must count the number of days that a person is on the queue. What we've done is added a dateslicer and these DAX-formulas:

 

unique clients = DISTINCTCOUNT('client'[client number])

unique number of days = DISTINCTCOUNT('fact'[client_date_unique])

 

So we count the distinct clients and the distinct number of clients per days.

 

Everything works great except when a cliënt is gone from queue.... When we take the dataset from above we get the following results:

 

6 okt 2014:

clientnumber         clients unique          number of days
1591                       1                              386
23897                     1                              379

 

7 okt 2014:

clientnumber         clients unique          number of days
1591                       1                              387
23897                     1                              380

 

8 okt 2014:

clientnumber         clients unique          number of days
1591                       1                              388
23897                     1                              380

 

But what we want:

clientnumber         clients unique          number of days
1591                       1                              388

 

So the problem is that because of the dateslicer cliënt 23897 is still on the queuelist, because of that he was here in past. But when somebody is gone from the queue on the enddate of the dateslicer he must be gone from the list.

 

We've tried many things but were not able to solve this untill now.

 

The .pbix with sample data, such as above is here: https://ufile.io/rx06o

 

I really hope that someone has an idea for us to solve this.

 

Ps; I'm also thinking about manipulating the 'length in days' column in source and display this one, but then we need to take the MAX() of this column, because of that 1 client can be 2 times on 1 date. And taking a MAX() gives other problems, such as a 'wrong' totalcolumn. So we would like to solve it with the current data if possible.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @MiKeZZa,

 

According to your description, you want to hide the records which last date is less than current selected date, right?
If this is a case, you can add conditions to check the last date.

 

unique clients = 
var clientId=LOOKUPVALUE(client[_clientid],client[client number],MAX('client'[client number]))
Return
IF(MAXX(FILTER(ALL('fact'),[_clientid]=clientId),[date])>=MAX('date'[datum]),DISTINCTCOUNT('client'[client number]),BLANK())

unique number of days = 
var clientId=LOOKUPVALUE(client[_clientid],client[client number],MAX('client'[client number]))
Return
IF(MAXX(FILTER(ALL('fact'),[_clientid]=clientId),[date])>=MAX('date'[datum]),DISTINCTCOUNT('fact'[client_date_unique]),BLANK())

1.PNG2.PNG

 

 

Regards,

Xiaoxin Sheng

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @MiKeZZa,

 

According to your description, you want to hide the records which last date is less than current selected date, right?
If this is a case, you can add conditions to check the last date.

 

unique clients = 
var clientId=LOOKUPVALUE(client[_clientid],client[client number],MAX('client'[client number]))
Return
IF(MAXX(FILTER(ALL('fact'),[_clientid]=clientId),[date])>=MAX('date'[datum]),DISTINCTCOUNT('client'[client number]),BLANK())

unique number of days = 
var clientId=LOOKUPVALUE(client[_clientid],client[client number],MAX('client'[client number]))
Return
IF(MAXX(FILTER(ALL('fact'),[_clientid]=clientId),[date])>=MAX('date'[datum]),DISTINCTCOUNT('fact'[client_date_unique]),BLANK())

1.PNG2.PNG

 

 

Regards,

Xiaoxin Sheng

Now we've added our whole customer dimension (30.000 records) and it's now SO slow; it doesn't work. It gives memory errors or it takes minutes to load the visual where the measures are used.

 

I think this is because of that the lookupvalue is looping through the data.

 

Is there anything else possible to also make it work in our larger dataset..?

Anonymous
Not applicable

Hi @MiKeZZa,

 

I modified the fact table as variable, perhaps you can try it if it can improve the performance:

unique clients = 
var clientId=LOOKUPVALUE(client[_clientid],client[client number],MAX('client'[client number]))
var maxDate=MAXX(FILTER(ALL('fact'),[_clientid]=clientId),[date])
Return
IF(maxDate>=MAX('date'[datum]),DISTINCTCOUNT('client'[client number]),BLANK())

unique number of days = 
var clientId=LOOKUPVALUE(client[_clientid],client[client number],MAX('client'[client number]))
var maxDate=MAXX(FILTER(ALL('fact'),[_clientid]=clientId),[date])
Return
IF(maxDate>=MAX('date'[datum]),DISTINCTCOUNT('fact'[client_date_unique]),BLANK())

Regards,

Xiaoxin Sheng

It improved a little, but not good enough. We've now made a different solution with SQL. Thanks for all the help.

Hi @Anonymous,

 

I have to take some time to understand what you've writted but it works really great. Lovely!!!!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors