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

Change a column value based on a date slicer

I have a Sales table

order_noorder_datefeeprojected_payment_datepayment_datepaid
12020-01-1310002020-04-15 FALSE
22020-02-2220002020-06-132020-06-15TRUE
32020-02-2730002020-07-012020-07-12TRUE
42020-03-1440002020--07-19 FALSE

 

And I calculate the value of the outstanding payments with the following measure:

Projected Revenue: No Payments Received = 

CALCULATE(CALCULATE(SUM(Sales[fee]),FILTER(Sales,Sales[paid]=FALSE))),USERELATIONSHIP(Sales[projected_payment_date],Dates[date]))
which would give the sum of the fee for order 1 and 4.
Now I want to be able to go back in time and see a snapshot of the payments that have yet to be received at that time.
So if I select 1 July 2020 in a Date Slicer, it should sum up the fees for 1,3 and 4, effectively treating the paid column for order 3 as FALSE instead of TRUE. So basically any payment_dates after the selected date, should change the paid column to false.
 
Any ideas on how I can achieve this?
1 ACCEPTED SOLUTION
Anonymous
Not applicable

This is what I ended up doing

 

Snapshot = 
VAR max_date = CALCULATE(MAX(Sales[order_date]),ALLSELECTED())
RETURN
CALCULATE(
(SUMX(CALCULATETABLE(Sales,Sales[order_date]<=max_date),[fee])-
SUMX(CALCULATETABLE(Sales,Sales[order_date]<=max_date,Sales[payment_date]<=max_date,Sales[paid]=TRUE),[fee])),
USERELATIONSHIP(Sales[projected_payment_date],Dates[date]))

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

This is what I ended up doing

 

Snapshot = 
VAR max_date = CALCULATE(MAX(Sales[order_date]),ALLSELECTED())
RETURN
CALCULATE(
(SUMX(CALCULATETABLE(Sales,Sales[order_date]<=max_date),[fee])-
SUMX(CALCULATETABLE(Sales,Sales[order_date]<=max_date,Sales[payment_date]<=max_date,Sales[paid]=TRUE),[fee])),
USERELATIONSHIP(Sales[projected_payment_date],Dates[date]))

 

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.