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
dakins
Helper II
Helper II

Dax issue - Multiple conditions on date data

Hello All,


I need help with my dax. 

 

In my data set, I have:
Type - New, return, or seasonal customers
Subscription level - Gold, Silver, Bronze, Diamond
Sub - Start and End date. 

 

Goal: I'd like to calculate how many days my customer went offline before resubscribing under certain conditions.

 

Scenario - if my customer type is new or return and customer sub level is gold or bronze then calculate the end date minus the start date of my customers next purchase if the customer type is seasonal. 

Answer = 150 days 

P.s - condition - Everytime a new or returning customer subs with level gold or bronze the system automatically assigns their next type to seasonal. 

Invoice noCustomer IDTypeSub levelStart date End date
101500NewGold8/1/20228/30/2022
102601ReturnDiamond10/1/202210/1/2023
103500SeasonalDiamond03/02/202303/30/2023
104606ReturnDiamond7/31/20238/2/2023
105700RetunBronze06/1/202306/30/2023
106700SeasonalBronze11/1/202311/26/2023
107701NewDiamond04/202305/2023

 

 

For the table above the dax should calculate:

Customer 500: 8/30/2022 - 03/02/2023 = 184 days

Customer 700: 6/30/2023 - 11/1/2023 = 124 days

 

 

 

Surveillance Days =
SWITCH (
    TRUE (),
    'Customer '[Type] = "New" ||'Customer '[Type] = "Return"
    && 'Customer '[Subscription level] = "Gold" || 'Customer '[Subscription level] = "Bronze" ,
    DATEDIFF ('Sub'[Start_Date], 'Sub'[End_Date], DAY),
    'Customer '[Type]= "Seasonal",
    DATEDIFF ('Sub'[Start_Date], 'Sub'[], DAY),
    BLANK ()
)






Thank you!
D
3 REPLIES 3
dakins
Helper II
Helper II

P.S - For every seasonal customer Type, the previous sub level must be gold or bronze.

dakins
Helper II
Helper II

Ahmedx, thank you.
The dax worked using the sample data set however when tested in my live data, it didn't work as expected.
In real world situation, customer 500 may have multiple transactions up to 5 or 6; hence the the dax has to tie every
gold or bronze to its next seasonal sub.

P.s - condition - Everytime a new or returning customer subs with level gold or bronze the system automatically assigns their next type to seasonal. 

Invoice noCustomer IDTypeSub levelStart date End date
99500NewSilver09/1/202011/1/2022
100700NewSilver11/2/20111/20/2021
101500NewGold8/1/20228/30/2022
103500SeasonalDiamond03/02/202303/30/2023



Ahmedx
Super User
Super User

pls try this

Screenshot_3.png

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors