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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
aggss
Frequent Visitor

Latest Date Filter based on an aggregated measure

I have the following problem that I can't quite find a solution for. I'm trying to filter a stacked bar chart to the latest complete date in my data.

 

The latest complete date is defined in my data as a date that has prices entered from at least two different sources.

This part seems to be working.

IncompleteDates = DISTINCTCOUNT(Prices[Source])<2
 
LastCompleteWk =
CALCULATE(
    MAX(DateTable[Date]),
    FILTER(
        ALL(DateTable[Date]),
        [IncompleteDates]=FALSE()
    ))
 
AvgPriceLastWk = 
CALCULATE(
AVERAGE(Prices[Price]),
FILTER(
    VALUES(DateTable),
    DateTable[Date] =[LastCompleteWk]
))
 
However, I'm running into problems when I try to use a slicer to filter the bar chart to one product. Even though I know that product has prices for the lastest week.
 
I'm also not sure if there is a better way to do this, any advice would be much appreciated.
1 ACCEPTED SOLUTION
v-yohua-msft
Community Support
Community Support

Hi, @aggss 

Based on your information, I create sample tables:

Price table:

vyohuamsft_0-1728357280918.png

 

Date table:

vyohuamsft_1-1728357291823.png

 

Then create new measures:

LastCompleteWk = 
CALCULATE(
    MAX('Date'[Date]),
    FILTER(
        ALL('Date'),
        CALCULATE(
            DISTINCTCOUNT('Price'[Source]),
            ALLEXCEPT('Price', 'Price'[Date], 'Price'[Product])
        ) >= 2
    )
)
AvgPriceLastWk = 
CALCULATE(
    AVERAGE('Price'[Price]),
    FILTER(
        VALUES('Date'),
        'Date'[Date] = [LastCompleteWk]
    )
)

 

Put them in visual, here is my preview:

vyohuamsft_2-1728357905049.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

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-yohua-msft
Community Support
Community Support

Hi, @aggss 

Based on your information, I create sample tables:

Price table:

vyohuamsft_0-1728357280918.png

 

Date table:

vyohuamsft_1-1728357291823.png

 

Then create new measures:

LastCompleteWk = 
CALCULATE(
    MAX('Date'[Date]),
    FILTER(
        ALL('Date'),
        CALCULATE(
            DISTINCTCOUNT('Price'[Source]),
            ALLEXCEPT('Price', 'Price'[Date], 'Price'[Product])
        ) >= 2
    )
)
AvgPriceLastWk = 
CALCULATE(
    AVERAGE('Price'[Price]),
    FILTER(
        VALUES('Date'),
        'Date'[Date] = [LastCompleteWk]
    )
)

 

Put them in visual, here is my preview:

vyohuamsft_2-1728357905049.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

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

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information. Do not include anything that is unrelated to the issue or question.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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