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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Rngomoa
Frequent Visitor

Counting two columns of TX_Curr and Valid_VL

Am trying to compute a count of clients with a valid_VL_1 as follows;

 

For a VL to be valid, it should be;

 

1. Have an order_date >-12 months from the selected month in the slicer.

2. Clients should have a deduplicated TX_Curr_lab=1.

3. The exit date> client visit date.

 

Each client has numerous visits and thus this dataset contains many duplicates.

 

1. Before I remove the duplicate, I need to select dates <= the selected dates in the slicer,

2. Then sort the data in descending order based on 3 columns i.e patient_id, mflcode and visit_date

3. Then select the most recent date.

4. Select if the visit_date-12 months from the selected month in the slicer "As Valid_VL" else "Not Valid_VL"

5. Then ensure each client is active as at the selected date on the slicer i.e (Their Next_appointment date>-28 days of the selected date in the slicer.

 

Below is the DAX I did.

 

However, when I plot Tx_curr_lab and Valid_VL_1, the numbers are the same. However, I expect the Valid_VL_1 < TX_Curr_lab since TX_Curr_lab is the denominator.

 

Valid_VL_1 =

 

VAR curdate = MAX(CalenderDate[dates])

VAR curdate2=MAXX(DATEADD(CalenderDate[dates],-28,DAY),CalenderDate[dates])

Var date_lab_ordered=MAXX(Lab_data,Lab_data[date_ordered])

VAR valid=IF(date_lab_ordered>MAXX(DATEADD(CalenderDate[dates],-12,MONTH),CalenderDate[dates]),"Valid","Not Valid")

 

RETURN

COUNTX( FILTER( ADDCOLUMNS( SUMMARIZE(Lab_data,Lab_data[Greencard.patient_id],Lab_data[Greencard.mflcode],"vl_curr2", CALCULATE(COUNT(Lab_data[Greencard.patient_id]),Lab_data[Greencard.visit_date] <= curdate && Lab_data[Greencard.visit_date] <= Lab_data[Lab_ExitDate1] && Lab_data[Greencard.next_appointment_date] > curdate2) ), "vl_curr3", IF([tx_curr2] > 0, 1, 0) ), [vl_curr3] > 0 && valid="Valid" && [TX_Curr_lab]=1 ),valid)

 

0 REPLIES 0

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.