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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
beer_not_bear
Regular Visitor

Filter expression by another column

Hello,

 

The following sales table exists:
[Entry DateTime], [Customer], [Item Sales Qty.], [Sales Amount].

 

Task:

For a specified period (e.g. 11/15/20 - 12/25/20, column [Entry DateTime]), take into account the amount (column [Sales Amount]) of only the first sales of customers (column [Customer]) in the total quantity of items (column [Item Sales Qty.]) not more than e.g. four (<= 4), the next sales are ignored.

 

Note: The required quantity of items can be sold over the entire period, but not more than the specified quantity.

Each sales line may contain a different quantity of items, also the sales amount.

 

---------------------------------------

An addition to the task description.

 

As far the function meets the conditions, it ignores the next lines.
For example, with the client ABC01524

beer_not_bear_0-1608279136135.png

The function, at this customer should take into account the sum of 2 items for 02.12.2020 and the sum of 2 items for 03.12.2020, the sum of the other 6 items for 03.12.2020 the function should ignore, as well as the next sale for 11.12.2020.

 

Here is sample of data: https://drive.google.com/file/d/1V_Qvoa_FZJZjen-0Jzai2KdopfKvG3Dw/view?usp=sharing

5 REPLIES 5
beer_not_bear
Regular Visitor

Hello @Greg_Deckler,

 

I tried to describe the task more in detail.

 

I understood that the price per unit would be needed.
That's why I added a column with the price per unit to the data sample.
But most probably this task will be hard to implement.

But still.

 

An addition to the task description.

As far the function meets the conditions, it ignores the next lines.


For example, with the client ABC01524

beer_not_bear_0-1608279183461.png

The function, at this customer should take into account the sum of 2 items for 02.12.2020 and the sum of 2 items for 03.12.2020, the sum of the other 6 items for 03.12.2020 the function should ignore, as well as the next sale for 11.12.2020.

Greg_Deckler
Community Champion
Community Champion

@beer_not_bear OK, thanks for the sample data, I have it downloaded. However, I do not fully understand what the results should be and why. Can you provide me a few rows of your expected output from the data you provided and explain how you got to those numbers? 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
beer_not_bear
Regular Visitor

Hi @Greg_Deckler ,

I provided an example of the data.
I lack my knowledge to deal with it.
Please, if you can help me.

beer_not_bear
Regular Visitor

Thank you @Greg_Deckler ,

I will try to implement your solution, if I fail I will provide a sample of data.

Have a nice evening.

Greg_Deckler
Community Champion
Community Champion

@beer_not_bear - Difficult to say with specificity without testing out something. Sample data would help greatly. However, you should be able to find a MIN date using variables or EARLIER for a customer. See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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