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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
Syndicate_Admin
Administrator
Administrator

DAX measure that calculates the list of transactions whose SUM is greater and less than $X

Hello everyone

Let's say I have the following fact table and also a calendar table.

Date Account Description Amount
5/5/2023 123 Legal 100k
5/6/2023 123 Legal 200k
5/6/2023 124 Rates 25k
5/7/2023 124 Legal 100k
5/8/2023 123 Rates 50k
5/9/2023 124 Incoming Transfer (270k)

The goal is to return the list of transactions per account whose SUM is greater than 250k or less than -250k.

Let's say I selected a date range from 5/5/2023 to 5/7/2023 in my Slicer. The following output is expected:

Date Account Description Amount
5/5/2023 123 Legal 100k
5/6/2023 123 Legal 200k

If for example I selected the range 5/7/2023 to 5/9/2023 my expected result would be BLANK given the following:

5/7/2023 124 Legal 100k
5/8/2023 123 Rates 50k
5/9/2023 124 Incoming Transfer (270k)

Account 124 sum ($170k)

Count 123 sum 50k

I have this Dax formula but it excludes transactions less than 250k and I need the GROUP of transactions that contribute to the condition per account.

FilteredTransactions =
VAR TotalTransactions = SUM('Cash Activity'[Transaction])
RETURN
IF(
OR(
TotalTransactions > 250000,
TotalTransactions < -250000
),
'Cash Activity'[Transactions],
BLANK()
)

Any idea how to achieve this?

Thanks in advance,

2 REPLIES 2
sevenhills
Super User
Super User

Try this 

Accounts Matching = 
var summaryTable = ADDCOLUMNS(SUMMARIZE(ALLSELECTED('Table'),'Table'[Account], "sumamt",
   CALCULATE(SUM('Table'[Amount]))), "MatchCheck", [sumamt] >= 250000 || [sumamt] <= -250000)

var c = COUNTROWS(summaryTable) -- Testing! ... RETURN C 

return if ( HASONEVALUE('Table'[Account])  
    , If( CONTAINS(summaryTable, [MatchCheck], TRUE(), 'Table'[Account], SELECTEDVALUE('Table'[Account])), 1, 0)
    , blank() )

 

Add filter for your needs

 

Sample scenarios:

sevenhills_0-1689921876178.png

sevenhills_1-1689921933472.png

 

Hope this helps!

 

 

foodd
Super User
Super User

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

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.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.