Reply
RichOB
Post Patron
Post Patron

Need help adding a date measure to finish off what I already have

Hi, my end goal here is to get the % from dividing the Total_Loss / Total Spent within the 01/04/2024 - 01/06/2024 date range.

 

Category nameCategoryDateCreditDebitAmount
Spent 1101/042024-250-25
Spent 1101/05/2024-405-45
Spent 2201/06/20240100-100
Spent 2201/07/2024515-10
Loss 1301/04202420416
Loss 1301/05/2024-1230-42
Loss 2401/06/202420020
Loss 2401/07/202430282

 

 

So far I have added an Amount column by subtracting the credit from the debit columns. (keep in mind this is fake data, the theory behind it is what I need) Then I:

 

1. Combined Category 1+2 in 1 measure:

Total_Spent = 
CALCULATE(
    SUM(Sheet[Amount]),
    KEEPFILTERS(Sheet[Category] IN {"1","2"}))
 
2. Combined Category 3+4 in another measure:
Total_Loss = 
CALCULATE(
    SUM(Sheet[Amount]),
    KEEPFILTERS(Sheet[Category] IN {"3","4"}))
 
3.  Amount_% = [Total_Loss] - [Total_Spent]. This gives me the end figures and % I  need

 

4. I'm having trouble with step 4 putting a 01/04/2024 - 01/06/2024 date range around it. Can you help with this end part, please?

 

Thanks

1 ACCEPTED SOLUTION
v-yohua-msft
Community Support
Community Support

Hi, @RichOB 

Try the following measures:

Total_Loss = 
CALCULATE(
    SUM('Table'[Amount]),
    KEEPFILTERS('Table'[Category] IN {3, 4}),
    DATESBETWEEN('Table'[Date], DATE(2024, 4, 1), DATE(2024, 6, 1))
)
Total_Spent = 
CALCULATE(
    SUM('Table'[Amount]),
    KEEPFILTERS('Table'[Category] IN {1, 2}),
    DATESBETWEEN('Table'[Date], DATE(2024, 4, 1), DATE(2024, 6, 1))
)
Amount_% = 
DIVIDE([Total_Loss], [Total_Spent], 0)

 

Here is my preview:

vyohuamsft_0-1728977673106.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yohua-msft
Community Support
Community Support

Hi, @RichOB 

Try the following measures:

Total_Loss = 
CALCULATE(
    SUM('Table'[Amount]),
    KEEPFILTERS('Table'[Category] IN {3, 4}),
    DATESBETWEEN('Table'[Date], DATE(2024, 4, 1), DATE(2024, 6, 1))
)
Total_Spent = 
CALCULATE(
    SUM('Table'[Amount]),
    KEEPFILTERS('Table'[Category] IN {1, 2}),
    DATESBETWEEN('Table'[Date], DATE(2024, 4, 1), DATE(2024, 6, 1))
)
Amount_% = 
DIVIDE([Total_Loss], [Total_Spent], 0)

 

Here is my preview:

vyohuamsft_0-1728977673106.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ray_aramburo
Super User
Super User

Assuming you want to specifically hardcode that period, then it would be:

Amonunt%InPeriod = CALCULATE([Amount_%], DATESBETWEEN('TableName'[Date], DATE(2024,4,1), DATE(2024,6,1)))




Did I answer your question? Give your kudos and mark my post as a solution!

Proud to be a Super User!





avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)