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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Lahari
Helper II
Helper II

I need to get list of column names when i have 2 date columns in a table

Hi Everyone,

 

I have scenario where i have 2 different date columns by name interviewed date and joining date in an employee table. 

Now i want to get list of employee based on interviewed date and joining date. 

In google i have searched many videos and blogs but i found measures showing Sum(tables[sales]) for ship date and order date and measures are as follows

sales for order date = Sum(tables[sales])

sales for ship date = calcaulate([sales for order date],userelationship(calendardate[date],tables[date])

Here i am getting total sales this is ok. But in my scenario i want list of employee names instead of total sales so anyone tell me what i need to change in the measure in order to get the list of employee name details.

 

please help me in writing this measure. Thanks in advance. 

1 ACCEPTED SOLUTION

I think this should be the appropriate data model

 

lbendlin_1-1689725413069.png

You can then use USERELATIONSHIP in your measures to temporarily activate each of the joins.

 

View solution in original post

6 REPLIES 6
lbendlin
Super User
Super User

Read about USERELATIONSHIP

 

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Hi @lbendlin 

 

I have taken a sample way to explain my scenario. But below is the real scenario where i am facing the issue. please go through the steps and tell me how to get list of users and their roles in a table based on date selection.  I am happy that i have a reply from your  end. 

 

I have a scenario where i need to compare list of users and their roles based on selected dates which is named as prior date and current date. This prior date is from the Comparision_Livedate(Calendartable1) and current date is coming from the Live_Date(Calendartable2). Here user will select in date slicer of his own, prior date and current date.

 

The prior and current dates are connected to main table REM_ROLE_ACCESS_AUDIT_DATA_RPT by column name Row_Load_Date.  the prior date - table REM_ROLE_ACCESS_AUDIT_DATA_RPT is having inactive relationship and current date  -REM_ROLE_ACCESS_AUDIT_DATA_RPT  is haivng active relationship.

 

 I am getting count of users and roles correctly with measures but the enduser need a table visual which shows list of prior users, prior roles, current users and current roles. by comparing the prior and current when the user and role is not present in prior but present in current then the prior user and role should be blank and highlighted with a color and in the same if user and role is not present in current but present in prior then the current user and current role should be blank and highlighted with a color.  if the user and role is present in both prior and current then it should be shown normally. 

 

In power bi the table visual is as follows

 

Lahari_0-1689498496375.png

 

 

This is the output i am expecting for the list of users and roles both for prior  and current dates.

The above pbi table visual is achieved by conditional formatting of column Full_Name and Role based on the count of prior roles and users, the count of current roles and users. but when the end user export this table visual as excel then conditional formatting of color is not exported and the enduser can see the list of full_name and roles even when they are not present in prior or current so they need to be formatted in power bi table visual itself based on the condition if they Full_Name and role is not presented then it should be blank. 

 

for the count of users and roles based on prior date and current date measures are as follows

 

count of prior users mesaure is

 

SD P3 Prior Period Users =
var _MINDATE = MIN(Comparision_LiveDate[Date])
var b = CALCULATE([P3 Prior Period Users],TREATAS({_MINDATE},Comparision_LiveDate[Date]))
RETURN
DIVIDE(b,[SD P3 Normalisation Factor])
 -------------------------------------------------------------
P3 Prior Period Users = var a = CALCULATE([Current Period Users],ALL(LiveDate),USERELATIONSHIP(LiveDate[Date],Comparision_LiveDate[Date]))*[Normalization Factor]
var b = IF(ISBLANK(a),0,a)
return b
 ---------------------------------------------------------------------
Current Period Users = var a = CALCULATE(DISTINCTCOUNTNOBLANK(REM_ROLE_ACCESS_AUDIT_DATA_RPT[FULL_NAME]),LiveDate[DateID],REM_ROLE_ACCESS_AUDIT_DATA_RPT[DateID_RLD])
var b = IF(ISBLANK(a),0,a)
return b
-----------------------------------------------------------
SD P3 Normalisation Factor =
var _MINDATE = MIN(Comparision_LiveDate[Date])
var b = CALCULATE([Normalization Factor],TREATAS({_MINDATE},Comparision_LiveDate[Date]))
RETURN
b
------------------------------------------------------------------------
Normalization Factor = COUNTROWS ( 'LiveDate' ) / COUNTROWS ( 'Comparision_LiveDate' )
--------------------------------------------------
the same for the count of prior roles where it is taken from the table of column roles.
 
for the count of current users and roles mesaures are as follows
 
count of current period users measure is 
 
SD P3 Current Period Users =
var _MINDATE = MIN(LiveDate[Date])
RETURN
CALCULATE([P3 Current Period Users],TREATAS({_MINDATE},LiveDate[Date])
)
 -----------------------------------------------------------------
P3 Current Period Users =
var a = CALCULATE(DISTINCTCOUNTNOBLANK(REM_ROLE_ACCESS_AUDIT_DATA_RPT[FULL_NAME]),LiveDate[DateID],REM_ROLE_ACCESS_AUDIT_DATA_RPT[DateID_RLD])
var b = IF(ISBLANK(a),0,a)
return b
 --------------------------------------------------------
the same for the count of current roles where it is taken from the table of column roles
 
Now here I tired many ways to get list of users and roles in prior by taking measure
 
Measure for the list of prior period users .
 
SD P3 Prior Period Users =
var _MINDATE = MIN(Comparision_LiveDate[Date])
var b = CALCULATE([P3 Prior Period Users],TREATAS({_MINDATE},Comparision_LiveDate[Date]))
var c = SELECTEDVALUE(REM_ROLE_ACCESS_AUDIT_DATA_RPT[FULL_NAME])
RETURN
if(DIVIDE(b,[SD P3 Normalisation Factor]) = 0BLANK(), c)
 
-----------------------------------------------------------
 here i have written a condition that if prior user is 0 then blank otherwise it should take column of Full_Name from the REM_ROLE_ACCESS_AUDIT_DATA_RPT((list of users are filtered based on the prior date selected from slicer with the Row_Load_date from the table REM_ROLE_ACCESS_AUDIT_DATA_RPT) in the same way for role as well.
 
for the current periord list of users and roles measure is as follows
 
List of current perior users measure is 
 
Current users = IF([SD P3 Current Period Users] > 0,SUMMARIZECOLUMNS(REM_ROLE_ACCESS_AUDIT_DATA_RPT[FULL_NAME]),BLANK())
--------------------------------------------------------------
same measure but taking column from roles of a table to get list of roles ( list of users are filtered based on the current date selected from slicer with the Row_Load_date from the table REM_ROLE_ACCESS_AUDIT_DATA_RPT). 

 

 i have written same condition for current user and current role as when it is 0 it should be blank otherwise it should be list of Full_Name from the table REM_ROLE_ACCESS_AUDIT_DATA_RPT

 

The measures are working fine for current user and roles to get list but when coming to prior user and role for list it showing blank even it is 1 and in my view the logic is its taking the list of users and roles from the current date only but not fromt the prior so its showing blank. now i need to do changes in the measure of prior user list and role list that to filter the table REM_ROLE_ACCESS_AUDIT_DATA_RPT, Full_Name column for the prior date and as the relationship is inactive between table REM_ROLE_ACCESS_AUDIT_DATA_RPT and prior date we need to make it active by userrelationship. 

 

so once this two conditions are considered in the measure then we can have list of users and roles for the prior date as well. 

---------------------------------------------------

The measure to be modified here is 

SD P3 Prior Period Users =
var _MINDATE = MIN(Comparision_LiveDate[Date])
var b = CALCULATE([P3 Prior Period Users],TREATAS({_MINDATE},Comparision_LiveDate[Date]))
var c = SELECTEDVALUE(REM_ROLE_ACCESS_AUDIT_DATA_RPT[FULL_NAME])
RETURN
if(DIVIDE(b,[SD P3 Normalisation Factor]) = 0BLANK(), c)

------------------------------------------------

But i tried to modify the measure for the list of prior users but i am not able to get desired output. So help me in solving this measure as per the desired output.

 

if any other approach is their to solve this issue then i can work in that perspective as well. 

 

please help me to solve this issue. Thanks in advance. 

I cannot help further if you cannot provide usable sample data.

Hi @lbendlin 

 

Thanks for the reply. The below is the sample file of input data and also the pbix file what i have worked upto right now. please do the needful to solve this issue. 

 

https://github.com/Lahari2808/SampleFileData.git

 

The above is the link for sample data. I hope positive response from your end.

I think this should be the appropriate data model

 

lbendlin_1-1689725413069.png

You can then use USERELATIONSHIP in your measures to temporarily activate each of the joins.

 

Hi @lbendlin

I will update with sample data now. 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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