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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
HFBackelor
Regular Visitor

Measure for KPI's based on latest status

Hello.

 

I am currently working on a report where i want to analyze a large dataset of commercial leases.

The target fuctionality is to have a report with a time-based slicer that can show both data from individual leases at any given point, and aggregated KPI's such as occupancy ratios, and how they've changed over time.

 

I've managed to create measures for producing the latest values/status for individual units, but those don't seem to work at an aggregated level, especially when trying to introduce filters based on latest status etc.

 

The dataset structure is similar to the one I'm posting below.

I really appreciate any help and/or pointers.

 

 

Unit IDLease IDLatest UpdateStatusArea
11-12021-12-31Let24
11-22022-03-31Let24
1 2022-06-30Vacant24
11-32022-08-01Let24
1 2023-06-01Vacant24
11-42023-07-01Let24
22-12019-01-01Let50
22-22023-09-01Let50
2 2023-11-01Vacant50
3 2016-11-30Vacant70
33-12017-01-01Let70
33-22018-03-01Let70
33-32021-08-01Let70
33-42022-04-01Let70
3 2023-01-01Vacant70
33-52023-05-25Let70

 

-*Update*-

 

Adding visualization of desired result, and description of the measure i've used so far to calculate latest value on unit level, and the measure i've been trying to combine it with to calculate aggregated KPI's for occupancy:

 

Below example would be the result of a slicer set at 2023-06-30

Unit IDLease IDLatest UpdateStatusArea
1 01/06/2023Vacant24
22-101/01/2019Let50
33-525/05/2023Let70

 

Aggregated occupancy rate would amount to 83%

 

Current Measure for latest value for area: 

Latest Area =
var LastArea = calculate(sum(Data[Area]),Data[Latest Update]=max(Data[Latest Update]))
Return sumx(values(Unit ID]),LastArea)
 
Current attempt at measure for aggregated occupancy that does not work:
Occupied Area =
var RelativeDate = calculate(max(Data[Latest Update]),Data[Latest Update]<=max('Calendar'[Date]))
var LatestUnitID = calculate(max(data[Unit ID]),Data[Status Update]=max(Data[Status Update]))
var DateTable1 = summarize(Data,Data[Unit ID],"RelativeStatusChange", RelativeDate)
var LatestStatusUpdate = maxx(DateTable1,[RelativeStatusChange])
var LatestStatus = lookupvalue(Data[Status],Data[Latest Update],LatestStatusUpdate,Data[Unit ID],LatestUnitID)

Return calculate(sumx(values(Data[Unit ID]),[Latest Area]),LatestStatus="Let")

 

 

1 ACCEPTED SOLUTION
v-yilong-msft
Community Support
Community Support

Hi, HFBackelor

Based on the information you have provided, Here are my answers to your questions.

  1. Make a date slicer.

date =

    CALENDAR(DATE(2016,1,12),DATE(2023,08,31)).

vyilongmsft_0-1704185366911.png

 

 

  1. Import the form as per your requirement.

vyilongmsft_1-1704185366914.png

 

 

  1. Create a measure for checking the nearest and farthest dates.

measure =

VAR _maxdate =

    MAXX ( ALLSELECTED ( 'date' ), 'date'[date] )

VAR _minxdate =

    MINX ( ALLSELECTED ( 'date' ), 'date'[date] )

RETURN

    CALCULATE (

        MAX ( 'Table (2)'[Latest Update] ),

        FILTER (

            ALL ( 'Table (2)' ),

            'Table (2)'[Latest Update] >= _minxdate

                && 'Table (2)'[Latest Update] <= _maxdate

                && 'Table (2)'[Unit ID] = SELECTEDVALUE ( 'Table (2)'[Unit ID] )

        )

    )

 

  1. Create a result and get its status based on the nearest date. Then you will get the latest status.
result =
    IF([measure] =
SELECTEDVALUE('Table (2)'[Latest Update],MAX('Table (2)'[Status],BLANK())
 

vyilongmsft_0-1704186462667.png

vyilongmsft_1-1704186488241.png

 

 

 

 

How to Get Your Question Answered Quickly 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Yilong Zhou

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

Hi, HFBackelor

Based on the information you have provided, Here are my answers to your questions.

  1. Make a date slicer.

date =

    CALENDAR(DATE(2016,1,12),DATE(2023,08,31)).

vyilongmsft_0-1704185366911.png

 

 

  1. Import the form as per your requirement.

vyilongmsft_1-1704185366914.png

 

 

  1. Create a measure for checking the nearest and farthest dates.

measure =

VAR _maxdate =

    MAXX ( ALLSELECTED ( 'date' ), 'date'[date] )

VAR _minxdate =

    MINX ( ALLSELECTED ( 'date' ), 'date'[date] )

RETURN

    CALCULATE (

        MAX ( 'Table (2)'[Latest Update] ),

        FILTER (

            ALL ( 'Table (2)' ),

            'Table (2)'[Latest Update] >= _minxdate

                && 'Table (2)'[Latest Update] <= _maxdate

                && 'Table (2)'[Unit ID] = SELECTEDVALUE ( 'Table (2)'[Unit ID] )

        )

    )

 

  1. Create a result and get its status based on the nearest date. Then you will get the latest status.
result =
    IF([measure] =
SELECTEDVALUE('Table (2)'[Latest Update],MAX('Table (2)'[Status],BLANK())
 

vyilongmsft_0-1704186462667.png

vyilongmsft_1-1704186488241.png

 

 

 

 

How to Get Your Question Answered Quickly 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Yilong Zhou

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

Ashish_Mathur
Super User
Super User

Hi,

Clearly show the expected result in a Table format.


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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.