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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
kageyoshi777
Frequent Visitor

value for min/max date for each item in table

I'm trying to show the difference between lowest/highest value of real estate offers next to eachother in one table.

I've got table like this.

 

advert_numberdata_downloadprice
11102.01.2020100
11103.01.2020200
11104.01.2020300

 

And measures..

 

 

Mindate = 
CALCULATE(MAX(estate_data[price]), FIRSTDATE(estate_data[date_download]))
Maxdate = 
CALCULATE ( max ( estate_data[price] ), LASTDATE(estate_data[date_download]))

 

 

 

But for some reason in few cases I dont see price for min/max date like in this example. 

Where I made an error? 

err.png

1 ACCEPTED SOLUTION

Hi  @kageyoshi777 ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can update the formula of measure [Mindate] and [Maxdate] as below:

Mindate = 
VAR _seladvert =
    SELECTEDVALUE ( 'estate_data'[advert_number] )
VAR _mindate =
    CALCULATE (
        MIN ( 'estate_data'[data_download] ),
        FILTER (
            ALLSELECTED ( 'estate_data' ),
            'estate_data'[advert_number] = _seladvert
        )
    )
RETURN
    CALCULATE (
        MAX ( 'estate_data'[price] ),
        FILTER (
            ALLSELECTED ( 'estate_data' ),
            'estate_data'[advert_number] = _seladvert
                && 'estate_data'[data_download] = _mindate
        )
    )
Maxdate = 
VAR _seladvert =
    SELECTEDVALUE ( 'estate_data'[advert_number] )
VAR _maxdate =
    CALCULATE (
        MAX ( 'estate_data'[data_download] ),
        FILTER (
            ALLSELECTED ( 'estate_data' ),
            'estate_data'[advert_number] = _seladvert
        )
    )
RETURN
    CALCULATE (
        MAX ( 'estate_data'[price] ),
        FILTER (
            ALLSELECTED ( 'estate_data' ),
            'estate_data'[advert_number] = _seladvert
                && 'estate_data'[data_download] = _maxdate
        )
    )

yingyinr_0-1657185716220.png

If the above one can't help you get the desired result, please provide more sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
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
ValtteriN
Super User
Super User

Hi,

For these kind of calculations I recommend using thins kind of pattern:

 

Maxdate = 
var _mdate = CALCULATE ( max (estate_data[date_download]),All(estate_data[advert_number]))return

CALCULATE ( max ( estate_data[price] ), all(estate_data[date_download]),estate_data[date_download]=_mdate)

 


The idea here is to first define the desired date in variable then remove some filter context using all and finally returnin filters to the calculation by using the variable defined. You might need to adjust the variable and ALL to get the desired outcome but the idea remains the same. If you have calendar table instead of using ALL(estate_data[date_download]) in the calculate you can use ALL(calendar).

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi, this solution does not solve my problem 😑. Of course for some "adverts" it works, like old measures worked too.

 

11.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

But for others still nothing. 

12.png

 

 

 

 

 

 

 

 

 

 

 

In this case I'm not using any data tables etc. Only plain data table like in my first post

Hi  @kageyoshi777 ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can update the formula of measure [Mindate] and [Maxdate] as below:

Mindate = 
VAR _seladvert =
    SELECTEDVALUE ( 'estate_data'[advert_number] )
VAR _mindate =
    CALCULATE (
        MIN ( 'estate_data'[data_download] ),
        FILTER (
            ALLSELECTED ( 'estate_data' ),
            'estate_data'[advert_number] = _seladvert
        )
    )
RETURN
    CALCULATE (
        MAX ( 'estate_data'[price] ),
        FILTER (
            ALLSELECTED ( 'estate_data' ),
            'estate_data'[advert_number] = _seladvert
                && 'estate_data'[data_download] = _mindate
        )
    )
Maxdate = 
VAR _seladvert =
    SELECTEDVALUE ( 'estate_data'[advert_number] )
VAR _maxdate =
    CALCULATE (
        MAX ( 'estate_data'[data_download] ),
        FILTER (
            ALLSELECTED ( 'estate_data' ),
            'estate_data'[advert_number] = _seladvert
        )
    )
RETURN
    CALCULATE (
        MAX ( 'estate_data'[price] ),
        FILTER (
            ALLSELECTED ( 'estate_data' ),
            'estate_data'[advert_number] = _seladvert
                && 'estate_data'[data_download] = _maxdate
        )
    )

yingyinr_0-1657185716220.png

If the above one can't help you get the desired result, please provide more sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.