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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
pravkan
Frequent Visitor

filter visual by previous day

I have build a dashboard in power bi desktop and I want the visual highlighted in yellow to be filtered by previous day.

Example if I chose 4th Aug in the slicer it should display sales data for 3rd Aug.

 

pravkan_0-1660407704104.png

 

What I have try so far is I have created a Measure 

Previous Day Sales = CALCULATE(SUM(V_RETAILER_SALES_BY_DISTRICTS[SALES_AMOUNT]),PREVIOUSDAY('DWH CALENDAR'[Date].[Date]))
but when am adding it on the visual its displaying nothing.

I have also created a calculated table but the problem is I have hardcoded value for previous day but I want it to display dynamic previous day value based on what I select on slicer value
 
Calculate Table Previous Day =
VAR PREV_DAY = "2022-08-03"
RETURN
CALCULATETABLE (
SUMMARIZE (
V_RETAILER_SALES_BY_DISTRICTS,
V_RETAILER_SALES_BY_DISTRICTS[Districts],
V_RETAILER_SALES_BY_DISTRICTS[Primary_City],
V_RETAILER_SALES_BY_DISTRICTS[Retailer_Name],
V_RETAILER_SALES_BY_DISTRICTS[SALES_AMOUNT],
V_RETAILER_SALES_BY_DISTRICTS[TRANSACTION_DATE]
),
FORMAT(V_RETAILER_SALES_BY_DISTRICTS[TRANSACTION_DATE],"YYYY-MM-DD") = PREV_DAY
)
 
Please help!
1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @pravkan ;

You could try it,

 

previous day = CALCULATE(SUM([ Sales]),PREVIOUSDAY('financials'[Date]),ALLEXCEPT(financials,financials[Product]))

 

I create a simple test file. we could find the final show:

AilsaTao_4-1660703188699.png


Best Regards,
Community Support Team _ Yalan Wu
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

2 REPLIES 2
v-yalanwu-msft
Community Support
Community Support

Hi, @pravkan ;

You could try it,

 

previous day = CALCULATE(SUM([ Sales]),PREVIOUSDAY('financials'[Date]),ALLEXCEPT(financials,financials[Product]))

 

I create a simple test file. we could find the final show:

AilsaTao_4-1660703188699.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

speedramps
Super User
Super User

It is best practice to use a Calandar table for all Power BI date logic

see https://www.youtube.com/watch?v=BtYn1hfdSAM

and https://www.youtube.com/watch?v=XjVLaVLluYE

and all the other Calandar training modules ... they are free !

 

Then your answer will be something like  ....

Previous day sales
CALCULATE
SUM(V_RETAILER_SALES_BY_DISTRICTS[SALES_AMOUNT]),
'CALENDAR'[Dayoffset] = -1)

 

Thanks for reaching out for help.

I put in a lot of effort to help you, now please quickly help me by giving kudos.

Remeber we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button. 

If you give someone a fish then you only give them one meal, but if you teach them how to fish then they can feed themselves and teach others for a lifetime.  I prefer to teach members on this forum techniques rather give full solutions and do their job. You can then adapt the technique for your solution, learn some DAX skills for next time and soon become a Power BI Super User like me. 

One question per ticket please. If you need to extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.