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! Learn more

Reply
eddd83
Resolver I
Resolver I

keep filter ( ) + filter ( all ( ) )

slicer: 

Date[Date] = Oct 24, 2020 (saturday)

 

Report:

LocationProductPosted Price
ChicagoApples1.25
ChicagoBanana1.75
ChicagoCarrots1.61

 

Produce Table:

LocationProductPosted PriceDate
ChicagoApples1.2510/23/20
ChicagoApples2.1210/24/20
ChicagoApples2.5110/25/20
ChicagoBanana1.7510/23/20
ChicagoBanana2.6510/24/20
ChicagoBanana2.7510/25/20
ChicagoCarrots1.6110/23/20
ChicagoCarrots2.4510/24/20
ChicagoCarrots2.4110/25/20
Chicago Mango0.7510/23/20

 

 

 

 

 

posted price =
VAR WeekDays =
    IF ( HASONEVALUE ( Dates[Date] ), VALUES ( Dates[Day Short] ), "Mon" )
VAR SelDate =
    IF ( HASONEVALUE ( Dates[Date] ), VALUES ( Dates[Date] ), TODAY () )
VAR PostedPricesWeekday =
    CALCULATE (
        MIN ( 'Posted Prices'[Price] ),
        'Posted Prices'[Price Date]
            = IF ( HASONEVALUE ( Dates[Date] ), VALUES ( Dates[Date] ), TODAY () )
    )
VAR PostedPricesSat =
    CALCULATE (
        MIN ( 'Posted Prices'[Price] ),
        KEEPFILTERS (
            FILTER (
                ALL ( 'Posted Prices'[Price Date] ),
                'Posted Prices'[Price Date] = SelDate - 1
            )
        )
    )
VAR PostedPricesSun =
    CALCULATE (
        MIN ( 'Posted Prices'[Price] ),
        KEEPFILTERS (
            FILTER (
                ALL ( 'Posted Prices'[Price Date] ),
                'Posted Prices'[Price Date] = SelDate - 2
            )
        )
    )
RETURN
    IF (
        WeekDays = "Sat",
        PostedPricesSat,
        IF ( WeekDays = "Sun", PostedPricesSun, PostedPricesWeekday )
    )

 

 

 

 

 

There's a many to 1 relationship between produce table [date] and date [date].

 

Even though the slicer says 10/24/2020, I want to show the last available weekday price, which is 10/23/2020 (friday) in this case. I have included filter ( all ( ) ) in my measure, otherwise, the 10/24/2020 filter context would only return the saturday value. However, I would still like to keep the filter context for location & product because otherwise my measure would return 0.75 (from mangos). I tried using Keepfilters, but i'm not achieving my desired result.

 

Help?

1 ACCEPTED SOLUTION
smpa01
Super User
Super User

@eddd83 not sure if you would like it, but I solved it using a different measure.

 

 

Revised Price := 
VAR _1 = MAX(Dates[Date])
VAR _2 = CALCULATE(MAX(Dates[Date]),FILTER(ALL(Dates),Dates[Date]<=_1&&[Max Revised date]<>0))
VAR _3 = CALCULATE([MaxPrice],ALL(Dates[Date]),Dates[Date]=_2)
RETURN _3

 

solve.PNG

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

5 REPLIES 5
smpa01
Super User
Super User

@eddd83 not sure if you would like it, but I solved it using a different measure.

 

 

Revised Price := 
VAR _1 = MAX(Dates[Date])
VAR _2 = CALCULATE(MAX(Dates[Date]),FILTER(ALL(Dates),Dates[Date]<=_1&&[Max Revised date]<>0))
VAR _3 = CALCULATE([MaxPrice],ALL(Dates[Date]),Dates[Date]=_2)
RETURN _3

 

solve.PNG

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@eddd83 did you try the solution provided?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
amitchandak
Super User
Super User

@eddd83 , Not very clear. You can have a date table with following columns

 

WeekDay = WEEKDAY([Date],2) //monday
Start of Week = [Date] -[WeekDay]+1 //monday
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)

 

Measure  =

var _max = maxx(allselected('Date'), 'Date'[Week Rank])

return

Calculate(min(Produce[Posted Price]) , filter(All('Date'), 'Date'[Week Rank]) =_max))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak 

 

sorry for the confusion. Please see the one drive link with my file:

 

https://onedrive.live.com/?authkey=%21APgzM8jL%2DrliMyw&cid=69E558AB6771FF6A&id=69E558AB6771FF6A%211...

 

Basically my measure (posted price) works for the weekdays, but returns a blank for the weekends. Ideally for the weekdays, it would show the previous friday (10/23) in this scenario.

Hi @eddd83 ,

 

You can create a new weekday column in your Date table :

 

weekday = WEEKDAY(Dates[Date],2)

 

Capture4.PNG

Then use REMOVEFILTER to clear filter from slicer in [posted price]:

 

_posted price = var a = IF(SELECTEDVALUE(Dates[weekday])<=5,MAX(Dates[Date]),CALCULATE(MAX(Dates[Date]),FILTER(ALL(Dates),Dates[Date]<=MAX(Dates[Date])&&Dates[weekday]<=5))) return CALCULATE(MIN('Posted Prices'[Price]),'Posted Prices'[Price Date] = a,REMOVEFILTERS(Dates[Date])) 

 

Capture5.PNG

 

For more details, please refer to the pbix file:  https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EUfmRSl0n3VLrP3tbk...

 

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

 

Best Regards,

Dedmon Dai

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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