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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
ariana_night
Frequent Visitor

Highest Value within last 3 years

Hello,

 

I am trying to write a measure that will bring me the qty of "152,027,444" shown in the below table visual since this is the highest the inventory level has been in the last 3 years. The table was filtered using relative date filter in filter panel. 

 

ariana_night_0-1658426385976.png

 

Why? because in another measure I will need to divide the qty of "145,590,538" shown below with the qty above to show end users the % difference between how much is on hand vs our highest level recorded within the last 3 years, in a card visual. 

 

ariana_night_1-1658426500319.png

 

Qty is 'Excess Inventory' [Excess Inventory Total Gross Inventory]

Date is 'Excess Inventory' [Report Date] - you can see this is recorded monthly

 

I was successful with getting the qty of "145,590,538" through this measure: (But need help with the other qty)

CALCULATE(SUM('Excess Inventory'[TotalGrossInv]), LASTDATE('Excess Inventory'[Report Date]))

 

Please let me know if you need additional information.

 

Best,

Ariana

 

 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

I tried to create a sample pbix file like below, and all measures are in the attached file.

 

Untitled.png


 

    Microsoft MVP




If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.





LinkedIn
Visit my LinkedIn page





Outlook Booking
Schedule a short Teams meeting to discuss your question.




View solution in original post

3 REPLIES 3
ariana_night
Frequent Visitor

For the purpose of helping others with similar inquiry:

 

1. I am connect to a live database, therefore I am only able to create new measures (nothing else, unless my request is significant enough to ask business development to create a new table/column on the back end).

2. There is already a calendar table in my database called Report Date that updates on a monthly basis, so I did not need to create a new calendar table 

3. The most useful measures for the purposes of my report that Jihwan suggested were: Qty measure, Top Qty Recent Three Years, and Qty Ratio vs Highest in Three Years - see my specific measures below

 

qty measure = 
    IF(
        HASONEVALUE('Excess Inventory'[Report Date]), SUM('Excess Inventory'[TotalGrossInv]))
top qty recent three years: = 
VAR _recentthreeyears =
    SUMMARIZE (
        CALCULATETABLE (
            'Excess Inventory',
            DATESINPERIOD ( 'Excess Inventory'[Report Date], LASTDATE ('Excess Inventory'[Report Date]), -3, YEAR )
        ),
        'Excess Inventory'[Report Date]
    )
VAR _addmonthlyqty =
    ADDCOLUMNS ( _recentthreeyears, "@monthlyqty", [qty measure] )
RETURN
    MAXX ( _addmonthlyqty, [@monthlyqty] )
qty ratio vs highest in three years = 
VAR _currentqty =
    CALCULATE (
        [qty measure],
        'Excess Inventory'[Report Date] = EOMONTH ( MAX ( 'Excess Inventory'[Report Date] ), 0 )
    )
RETURN
    DIVIDE ( _currentqty, [top qty recent three years:] )

 

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

I tried to create a sample pbix file like below, and all measures are in the attached file.

 

Untitled.png


 

    Microsoft MVP




If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.





LinkedIn
Visit my LinkedIn page





Outlook Booking
Schedule a short Teams meeting to discuss your question.




This has helped - thank you so much!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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