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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
okusai3000
Helper IV
Helper IV

Two dates and USERELATIONSHIP

Hello everyone,

 

I'm getting nuts trying to solve the following.

 

  • I have a table with VISITS to PATIENTS. 
  • Each visit is related to a PATIENT_ID.
  • Could happen that you have 2 visits to the same patient and same month.
  • Each patient will be signing a form in one moment in time. This will be registered in another column as a date ([CON_VIS_CLI).

We need to know how many people signed the form each month and how many people have we seen in total in that month.

 

For the first requeriment, I solved it using:

 

Signed People=

CALCULATE(
DISTINCTCOUNT(INDICADORES_VISITAS[ID_PACIENTE]);
USERELATIONSHIP(INDICADORES_VISITAS[CON_VIS_CLI];Calendario[Date]))
 
Talking about the people that we have visited, and still have not signed, I was doing
[Signed People] + 
CALCULATE(
DISTINCTCOUNT(INDICADORES_VISITAS[ID_PACIENTE]);
USERELATIONSHIP(INDICADORES_VISITAS[CON_VIS_CLI]=BLANK()))
 
The problem with this is that once the patient has signed, he will be not counting anymore on that measure, meaning that the numbers will be moving with the time.
 
So, what I need to do is to get a Measure where I can grab, all the different PATIENTS_ID, from the VISITS we have done in that month, that their [CON_VIS_CLI] is BLANK OR HIGHER than the selected month.
 
In other words, If I'm checking the Visited Patients from January, and someone signed on March, HE SHOULD STILL APPEAR IN JANUARY AS HE DIDN'T SIGNED. Otherwise with my old Measure, he would have dissapeared.
 
Does anyone have an idea what should I do?
 
Millions of thanks!!
 

 

1 ACCEPTED SOLUTION
vivran22
Community Champion
Community Champion

Hello @okusai3000 

 

Try this:

Form Not Signed = 

VAR _SignFormDateChek = 
    FILTER(dtPatient,
    ISBLANK(dtPatient[[CON_VIS_CLI]) || dtPatient[[CON_VIS_CLI] > dtPatient[Vistit Date]
    )
    
VAR _RowCount = 
    CALCULATE(DISTINCTCOUNT(dtPatient[PATIENT_ID]),_SignFormDateChek
    )
RETURN
_RowCount

 

Cheers!
Vivek

If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂

https://www.vivran.in/

Connect on LinkedIn

View solution in original post

3 REPLIES 3
vivran22
Community Champion
Community Champion

Hello @okusai3000 

 

Try this:

Form Not Signed = 

VAR _SignFormDateChek = 
    FILTER(dtPatient,
    ISBLANK(dtPatient[[CON_VIS_CLI]) || dtPatient[[CON_VIS_CLI] > dtPatient[Vistit Date]
    )
    
VAR _RowCount = 
    CALCULATE(DISTINCTCOUNT(dtPatient[PATIENT_ID]),_SignFormDateChek
    )
RETURN
_RowCount

 

Cheers!
Vivek

If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂

https://www.vivran.in/

Connect on LinkedIn

Sir, I simply LOVE YOU. 

 

That was the solution.. Thank you so much.

 

 

Form Not Signed = 

VAR _SignFormDateChek = 
    FILTER(dtPatient,
    ISBLANK(dtPatient[[CON_VIS_CLI]) || dtPatient[[CON_VIS_CLI] >= dtPatient[Vistit Date]
    )
    
VAR _RowCount = 
    CALCULATE(DISTINCTCOUNT(dtPatient[PATIENT_ID]),_SignFormDateChek
    )
RETURN
_RowCount

 

 

v-juanli-msft
Community Support
Community Support

Hi @okusai3000 

Could you show a simple example and expected result to make me clear?

 

Best Regards

Maggie

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors