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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Card with value of last week with an amount

Hi all,

 

I have a date table and a transaction table.

The date table has more dates than the transaction table.
I want to create a card showing the value of the last with week a value.
Somehow my formula doesn't work though....

 

It's probably simple, but I just can't see how I fix this.

Who can help me please?


My formula:

amount of max week =
VAR lastweekwithamount = CALCULATE(MAX('Date'[Week]),ALLSELECTED('Transaction'[Amount]))
RETURN
CALCULATE(SUM('Transaction'[Amount]), 'Date'[Week] = lastweekwithamount)


It shows a blank in my card. It's probably because there are only transactions in week 1 and 2, not in the later weeks....

If I create a table with the week and the amount, it only shows week 1 and 2.
I want to see the value of week 2 as a result of my formula - to present in a card - , but this doesn't happen. Why?

 

example.jpg

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I found the solution I needed myself in the meanwhile:

amount of max week =
VAR AmountsGreaterThanZero = FILTER('Transaction','Transaction'[Amount]>0)
VAR LastWeekWithAmountGreaterThanZero = CALCULATE(MAX('Date'[Week]),AmountsGreaterThanZero)
RETURN
CALCULATE(
SUM('Transaction'[Amount]),
FILTER('Date','Date'[Week]=LastWeekWithAmountGreaterThanZero),
AmountsGreaterThanZero

)

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

I found the solution I needed myself in the meanwhile:

amount of max week =
VAR AmountsGreaterThanZero = FILTER('Transaction','Transaction'[Amount]>0)
VAR LastWeekWithAmountGreaterThanZero = CALCULATE(MAX('Date'[Week]),AmountsGreaterThanZero)
RETURN
CALCULATE(
SUM('Transaction'[Amount]),
FILTER('Date','Date'[Week]=LastWeekWithAmountGreaterThanZero),
AmountsGreaterThanZero

)
ryan_mayu
Super User
Super User

@Anonymous 

maybe you can try

amount of max week =
VAR lastweekwithamount = year(MAX('Transaction'[Date]))&month((MAX('Transaction'[Date]))
RETURN
CALCULATE(SUM('Transaction'[Amount]), 'Date'[Week] = lastweekwithamount)





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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