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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors