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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Max month for max year

Hi everyone, 

 

I'm trying to calculate an inventory turnover with Power BI.

 

I want to divide those two columns : Volume that we have in stocks / volume that we sold (for that, it is ok, my measure is a simple divide)

And then I want to divide it by the last month of the last year 

I've tried this, but it doesn't work :

Max month = CALCULATE(
MAX('Company$Commision Entries'[Mois]),
FILTER('Company$Commision Entries',MAX('Company$Commision Entries'[Année nbre]))
)
It always says as a response "12", I have indeed 12 months for 2023 but I have only 5 for 2024, as it is related to may.
My months and years are in numbers. 
 
Does someone have an idea please ? 
 
Thanks 🙂
1 ACCEPTED SOLUTION
ManuelBolz
Responsive Resident
Responsive Resident

Hello @Anonymous 

If my post helped you, please give me a 👍kudos and mark this post with Accept as Solution.

If I understood you correctly, this should be your solution.

VAR LastYear = MAX('Company$Commision Entries'[Année nbre])
VAR MaxMonth = 
    CALCULATE(
        MAX('Company$Commision Entries'[Mois]),
        FILTER(
            'Company$Commision Entries',
            'Company$Commision Entries'[Année nbre] = LastYear
        )
    )
RETURN
    DIVIDE(
        [Volume in Stock], 
        [Volume Sold] * MaxMonth
    )


Best regards from Germany
Manuel Bolz


🟦Follow me on LinkedIn
🟨How to Get Your Question Answered Quickly
🟩Fabric Community Conference
🟪My Solutions on Github

View solution in original post

3 REPLIES 3
mh2587
Super User
Super User

InventoryTurnoverLastMonthLastYear = //Try this might help you
VAR LastYear = CALCULATE(
    MAX('Company$Commision Entries'[Année nbre]),
    ALL('Company$Commision Entries')
)
VAR MaxMonthLastYear = CALCULATE(
    MAX('Company$Commision Entries'[Mois]),
    FILTER(
        'Company$Commision Entries',
        'Company$Commision Entries'[Année nbre] = LastYear
    )
)
RETURN
DIVIDE(
    CALCULATE(
        SUM('Company$Commision Entries'[VolumeInStock]),
        FILTER(
            'Company$Commision Entries',
            'Company$Commision Entries'[Année nbre] = LastYear &&
            'Company$Commision Entries'[Mois] = MaxMonthLastYear
        )
    ),
    CALCULATE(
        SUM('Company$Commision Entries'[VolumeSold]),
        FILTER(
            'Company$Commision Entries',
            'Company$Commision Entries'[Année nbre] = LastYear &&
            'Company$Commision Entries'[Mois] = MaxMonthLastYear
        )
    ),
    0
)

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



ManuelBolz
Responsive Resident
Responsive Resident

Hello @Anonymous 

If my post helped you, please give me a 👍kudos and mark this post with Accept as Solution.

If I understood you correctly, this should be your solution.

VAR LastYear = MAX('Company$Commision Entries'[Année nbre])
VAR MaxMonth = 
    CALCULATE(
        MAX('Company$Commision Entries'[Mois]),
        FILTER(
            'Company$Commision Entries',
            'Company$Commision Entries'[Année nbre] = LastYear
        )
    )
RETURN
    DIVIDE(
        [Volume in Stock], 
        [Volume Sold] * MaxMonth
    )


Best regards from Germany
Manuel Bolz


🟦Follow me on LinkedIn
🟨How to Get Your Question Answered Quickly
🟩Fabric Community Conference
🟪My Solutions on Github

Anonymous
Not applicable

Thank you for your help !! it works 😄 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.