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

Row level calculation based on date selected

Hi,

 

  I have a table with a Original_Date field on each row. I will have a date slicer for user to pick the date. 

 

  I need to use a Matrix with Group, Tenant, Type in Rows and a new calculated field in Values. This new field will calculate Days_Outstanding (= User's Date - Original_Date). 

 

  The issue is that this calculation first needs to happen on each row and each Group+Tenant+Type is not unqiue, so I can't use User's Date - Max(Original_Date) in DAX. My idea is create a dynamic temp table that refreshes itself depend on User's Date but I don't know how.

 

  Here is an example in Excel: Col A-E are source data. Col F links to user's selected date so it's dynamic, then col G calculation will update. However I'm not sure how to implement something similar in Power BI using DAX.

yuanye710_0-1619464069043.png

 

Having problem to attach a pbix file, so I pasted the data here. Thank you!

IDGroupTenantTypeOriginal_Date
1ATenant A1Rent1/2/2018
2ATenant A1Rent1/3/2019
3ATenant A1Payment1/6/2021
4ATenant A2Rent4/26/2019
5ATenant A2Rent5/4/2018
6ATenant A2Payment4/30/2020
7BTenant B1Rent9/4/2019
8BTenant B1Payment12/12/2018
9BTenant B1Rent2/5/2020
10BTenant B2Rent2/12/2020
11BTenant B2Payment3/27/2018
12BTenant B2Rent4/14/2020
13CTenant C1Rent3/8/2018
14CTenant C1Rent10/16/2018
15CTenant C1Payment5/8/2019
16DTenant D1Rent10/30/2018
17DTenant D1Payment4/30/2020
18DTenant D2Rent7/30/2018
19DTenant D2Rent1/11/2019
20DTenant D2Payment3/5/2019

 

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Anonymous 

You cannot update a table from a slicer as the model is completed and loaded. To achieve your goal, you can create a measure based on the user's date selection:

Days Outstanding = 
var __dateselected = SELECTEDVALUE(Dates[Date]) return
SUMX(
    Table3,
   DATEDIFF( __dateselected ,Table3[Original_Date],DAY )
)

 

Fowmy_0-1619468763311.png

 

 

 


 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
Fowmy
Super User
Super User

@Anonymous 

You cannot update a table from a slicer as the model is completed and loaded. To achieve your goal, you can create a measure based on the user's date selection:

Days Outstanding = 
var __dateselected = SELECTEDVALUE(Dates[Date]) return
SUMX(
    Table3,
   DATEDIFF( __dateselected ,Table3[Original_Date],DAY )
)

 

Fowmy_0-1619468763311.png

 

 

 


 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Thanks a lot! It's working!

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.