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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
RYRY
Frequent Visitor

Automatically calculate a "previous value" based on current slicer selection

Let's say, I have two slicers:

1. Days of the Week (Monday through to Sunday in that order)

2. Previous Day of the Week (same as above)

 

Both slicers have seven values each and are identical. What I am wanting to achieve is to eliminate the need of the second slicer by only using the first one. If I select a value on the first slicer, the "previous day" should be selected on the second slicer.

 

I am using these slicers days to calculate something, so ideally, I'd like to not have to use a second slicer but reference a measure (or some calulated value) that is based on the first slicer.

 

Here is my attempt at a calculate function but I get a syntax error. 

 

Submitted Applications Previous Day = CALCULATE(
    COUNT(DIM_Applicant[app_id]),
       'DIM_Applicant'[app_status] = "Active",
        REMOVEFILTERS(),
        DIM_Applicant[day_submitted] = [Previous Day]    
)

 

My [previous day] is a measure I created like so

Previous Day =
  SELECTEDVALUE('DIM_Day'[day_of_week]) & SELECTEDVALUE('DIM_Day'[day_number]) -1
 
 
My error is 
A function 'PLACEHOLDER' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

 

Thank you

1 ACCEPTED SOLUTION
v-fenling-msft
Community Support
Community Support

Thanks for lbendlin's concern about this issue.

 

Hi, @RYRY 

Since you did not give me some test data to test, I assumed some data myself:

DIM_Applicant:

vfenlingmsft_0-1736302304020.png

 

DIM_day:

vfenlingmsft_1-1736302360482.png


I will provide some steps below which I hope will help you:
First, create a calculated column in the DIM_day table:

vfenlingmsft_2-1736302387244.png

Previous Day of Week = 
SWITCH(
    'DIM_Day'[day_of_week],
    "Monday", "Sunday",
    "Tuesday", "Monday",
    "Wednesday", "Tuesday",
    "Thursday", "Wednesday",
    "Friday", "Thursday",
    "Saturday", "Friday",
    "Sunday", "Saturday"
)


Then create the following three Measure in order:

Selected Day = SELECTEDVALUE('DIM_Day'[day_of_week])
Previous Day = 
CALCULATE(
    MAX('DIM_Day'[Previous Day of Week]),
    FILTER(
        DIM_Day,
        'DIM_Day'[day_of_week] = [Selected Day]
    )
)
Submitted Applications Previous Day = 
CALCULATE(
    COUNT(DIM_Applicant[app_id]),
    'DIM_Applicant'[app_status] = "Active",
    FILTER(
        ALL(DIM_Applicant),
        DIM_Applicant[day_submitted] = [Previous Day]
    )
)

Select Card visual and drag Measure Submitted Applications Previous Day into Card visual:

vfenlingmsft_3-1736302535491.png

 


I have attached the pbix file for this example below, I hope it helps!

 

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-fenling-msft
Community Support
Community Support

Thanks for lbendlin's concern about this issue.

 

Hi, @RYRY 

Since you did not give me some test data to test, I assumed some data myself:

DIM_Applicant:

vfenlingmsft_0-1736302304020.png

 

DIM_day:

vfenlingmsft_1-1736302360482.png


I will provide some steps below which I hope will help you:
First, create a calculated column in the DIM_day table:

vfenlingmsft_2-1736302387244.png

Previous Day of Week = 
SWITCH(
    'DIM_Day'[day_of_week],
    "Monday", "Sunday",
    "Tuesday", "Monday",
    "Wednesday", "Tuesday",
    "Thursday", "Wednesday",
    "Friday", "Thursday",
    "Saturday", "Friday",
    "Sunday", "Saturday"
)


Then create the following three Measure in order:

Selected Day = SELECTEDVALUE('DIM_Day'[day_of_week])
Previous Day = 
CALCULATE(
    MAX('DIM_Day'[Previous Day of Week]),
    FILTER(
        DIM_Day,
        'DIM_Day'[day_of_week] = [Selected Day]
    )
)
Submitted Applications Previous Day = 
CALCULATE(
    COUNT(DIM_Applicant[app_id]),
    'DIM_Applicant'[app_status] = "Active",
    FILTER(
        ALL(DIM_Applicant),
        DIM_Applicant[day_submitted] = [Previous Day]
    )
)

Select Card visual and drag Measure Submitted Applications Previous Day into Card visual:

vfenlingmsft_3-1736302535491.png

 


I have attached the pbix file for this example below, I hope it helps!

 

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

use + instead of &

RYRY
Frequent Visitor

My [previous day] measure works out with no errors. It's when referencing this measure in the calculate function it gets the synrax error.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.