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
chamomile16
Frequent Visitor

Create a measure to include latest data across category rather than within category in a Treemap

I have the below data:

ReportingDateValuationTypeClosingValuation
3/30/2023Recent acquisition cost100
3/30/2023External Manager229
3/30/2023Independent Valuation300
3/30/2023NULL400
3/30/2023Internal Valuation90
3/30/2023Recent transaction price780
6/30/2020External Manager50
6/30/2020Independent Valuation50
6/30/2020NULL56
6/30/2020Desktop Review606
6/30/2020Internal Valuation60

 

I created a measure with the DAX code like below. I want to show the sum of latest valuation (valuation with latest reporting date) by default (not applying any filters).

 

Total Latest Valuation = 
  
VAR SelectedDate = SELECTEDVALUE ( 'I&RR Valuation'[Reporting Date] )  

VAR EffectiveDate =  
    IF (  
        ISBLANK(SelectedDate),  
        IF (  
            HASONEVALUE('I&RR Valuation'[Reporting Date]),  
            VALUES('I&RR Valuation'[Reporting Date]),  
            CALCULATE (  
                MAX('I&RR Valuation'[Reporting Date]),  
                ALLSELECTED('I&RR Valuation')  
            )  
        ),  
        SelectedDate  
    )  
  

RETURN  
    CALCULATE (  
        SUM('I&RR Valuation'[Closing Valuation]),  
        'I&RR Valuation'[Reporting Date] = EffectiveDate
    )  

 

 

The code works fine for my other visuals, but when I use it as the Values of my treemap, and use ValuationType as Category, it isn't working as expected:

chamomile16_0-1714806554289.png

Here, Desktop Review should not be included, as the latest reporting date for records with this Valuation Type is 2020-06-30. 2020-06-30 is not the latest reporting date in the table.

 

What I want is only records with reporting date = 2023-03-30 as this is the latest reporting date in the table. Expected output:

chamomile16_1-1714806972852.png

I can get this expected output when selecting 2023-03-30 in the ReportingDate filter. It doesn't show this expected result when no filters are applied.

 

Looks like the issue is that the treemap determines the latest valuation within each category rather than across categories, so it includes the sum of latest valuation per valuation type.

Is there a way to have the treemap show the expected result, by modifying DAX code, ignoring category when determing latest valuation or any other methods?

 

I hope my description of the problem makes sense. Thanks very much for any advices/hints!

6 REPLIES 6
chamomile16
Frequent Visitor

Note: I forgot to mention in the original post that I enabled personalized visualization for my report.

Therefore, only modifying DAX to include ValuationType may not be the best solution, as users may select other columns as Category when personalizing the visual. 

 

This is also the reason why this problem gives me so much headache......really need some pro's help please! Thank you!!

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1714873240348.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish, I really appreciate your input!

I tweaked and applied it to my report, and it works great when it's in default state.

 

When I apply other filters, for example, Investment, I hope it to show the latest valuation for that investment.

E.g., when I select Apple in my filter, the expected result is to show the latest valuation for Apple (on 2020-06-30), with Valuation Type External Manager and Desktop Review.

ReportingdateInvestmentValuation TypeClosing Valuation
3/30/2023ABC propertyRecent acquisition cost100
3/30/2023BE propertyExternal Manager229
3/30/2023 Independent Valuation300
3/30/2023 NULL400
3/30/2023 Internal Valuation90
3/30/2023 Recent transaction price780
6/30/2020AppleExternal Manager50
6/30/2020BananaIndependent Valuation50
6/30/2020 NULL56
6/30/2020AppleDesktop Review606
6/30/2020 Internal Valuation

60   

 

But what it actually shows is Blank(), as 2020-06-30 is not the latest reporting date for whole table.

 

In my previous code, I used the highlighted part below to have this function work for my other visuals, but unfortunately I think this is exactly what caused my original problem in the treemap (the Desktop Review that shouldn't be there in default state) 

 

VAR SelectedDate = SELECTEDVALUE ( 'I&RR Valuation'[Reporting Date] )

VAR EffectiveDate =
IF (
ISBLANK(SelectedDate),
IF (
HASONEVALUE('I&RR Valuation'[Reporting Date]),
VALUES('I&RR Valuation'[Reporting Date]),
CALCULATE (
MAX('I&RR Valuation'[Reporting Date]),
ALLSELECTED('I&RR Valuation')
)
),
SelectedDate
)

 

Is there possibly a way to get the expected result when applying other filters, so it doesn't only show the latest reporting date of the whole table? I understand that this may be hard, and thanks again for helping!

 

Hi,

See this revised file.

Ashish_Mathur_0-1714963597158.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish, thanks for the revised version. It seems to work fine for Apple, but consider if we have ABC property data as below, it will be showing both Recent acquisition cost and Internal Valuation while the desired output is Recent acquisition cost as it's the latest one for ABC property.

ReportingdateInvestmentValuation TypeClosing Valuation
3/30/2023ABC propertyRecent acquisition cost100
3/30/2023BE propertyExternal Manager229
3/30/2023 Independent Valuation300
3/30/2023 NULL400
3/30/2023 Internal Valuation90
3/30/2023 Recent transaction price780
6/30/2020AppleExternal Manager50
6/30/2020BananaIndependent Valuation50
6/30/2020 NULL56
6/30/2020AppleDesktop Review606
6/30/2020ABC propertyInternal Valuation

60   



You are very unclear about your own data/scenarios.  it jsut wasted my time to offer solutions for every scenrio that yo come up with. Think through all your scenarios very well and come up with a representative example/expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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