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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
plover
Advocate II
Advocate II

Calculate if any month greater than value

Hi there

 

I am attempting to write a report that will allow me to see any accounts that have a spending amount per month OVER a certain amount. If they do, then they are eligible for discounts etc.

 

I am looking for a way to look back say 12 months, and if a customer has ANY month with an amount greater tha 100,000 then return them - even if it was only 1 month.

 

My current measure only works if the TOTAL for the 12 months is over the amount, so not quite what i was after. Any help appreciated.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but I tried to create a sample pbix file and the sample measures like below. I amended the question to check recent four months sales per each customer, but I hope you can change this to recent 12 months in your datamodel.

I hope the below sample can provide some ideas on how to create a solution for your datamodel.

 

Jihwan_Kim_1-1669008875000.png

 

 

Jihwan_Kim_0-1669008851922.png

 

Sales measure: = 
SUM(Sales[Sales])
Recent four months sales: = 
CALCULATE (
    [Sales measure:],
    KEEPFILTERS (
        DATESINPERIOD ( 'Calendar'[Date], EOMONTH ( TODAY (), 0 ), -4, MONTH )
    )
)

 

Expected reult measure: = 
COUNTROWS (
    SUMMARIZE (
        FILTER (
            ADDCOLUMNS (
                SUMMARIZE ( Sales, Customer[Customer], 'Calendar'[Month-Year] ),
                "@recentfourmonthsmonthlysales", [Recent four months sales:]
            ),
            [@recentfourmonthsmonthlysales] > 100000
        ),
        Customer[Customer]
    )
) + 0

 

 

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but I tried to create a sample pbix file and the sample measures like below. I amended the question to check recent four months sales per each customer, but I hope you can change this to recent 12 months in your datamodel.

I hope the below sample can provide some ideas on how to create a solution for your datamodel.

 

Jihwan_Kim_1-1669008875000.png

 

 

Jihwan_Kim_0-1669008851922.png

 

Sales measure: = 
SUM(Sales[Sales])
Recent four months sales: = 
CALCULATE (
    [Sales measure:],
    KEEPFILTERS (
        DATESINPERIOD ( 'Calendar'[Date], EOMONTH ( TODAY (), 0 ), -4, MONTH )
    )
)

 

Expected reult measure: = 
COUNTROWS (
    SUMMARIZE (
        FILTER (
            ADDCOLUMNS (
                SUMMARIZE ( Sales, Customer[Customer], 'Calendar'[Month-Year] ),
                "@recentfourmonthsmonthlysales", [Recent four months sales:]
            ),
            [@recentfourmonthsmonthlysales] > 100000
        ),
        Customer[Customer]
    )
) + 0

 

 

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

amitchandak
Super User
Super User

@plover .Assume you have measure M1 and customer dimension and Date Table

 

Rolling 12 = calculate(Countx(Filter( Values(Customer[Customer]), [M1] >100000 ) ,[Customer]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,MONTH))

 

Rolling 12 should 1 or more or not blank

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

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.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.