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
aakif_xec
New Member

DAX Flag column by grouping other rows

Hello community,

 

I need help in understanding the DAX required based on the logical conditions available.
Consider the data - 

aakif_xec_0-1718708064904.png

 

Gain flag = 1 when,
1. Date = first_order_date
2. There should not be any sale from the customer for previous 12 months
3. Once the first condition satisfies, the next 11 months for the same customer should follow the same flag. For instance, if order date = 1/1/2022 and first order date = 1/1/2022, then flag = 1 for this customer untill the order date is less than 1/1/2023.

 

I'm unable to get the 3rd conditions, facing circular dependency errors.

Any advise will be helpful.   

 

@rajendraongole1 
@Ritaf1983 

@amitchandak 

@Greg_Deckler 
@Ashish_Mathur 

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

@aakif_xec Any chance you can post the data as text in a table?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler,
I have also included the optional output as output 2.
I need to either populate the 1 for 12 months including the current month, or insert order date + 1 year, same date for the 12 months against the respective customer. 
 

Datefirst_order_dateSalesNameGAINOutput required 1Output required 2
1/1/20221/1/202219999Customer A111/1/2023
2/1/20221/1/202219999Customer A011/1/2023
3/1/20221/1/202219999Customer A011/1/2023
4/1/20221/1/202219999Customer A011/1/2023
5/1/20221/1/202219999Customer A011/1/2023
6/1/20221/1/202219999Customer A011/1/2023
7/1/20221/1/202219999Customer A011/1/2023
8/1/20221/1/202219999Customer A011/1/2023
9/1/20221/1/202219999Customer A011/1/2023
10/1/20221/1/202219999Customer A011/1/2023
11/1/20221/1/202219999Customer A011/1/2023
12/1/20221/1/202219999Customer A011/1/2023
1/1/20231/1/202219999Customer A00 
2/1/20231/1/202219999Customer A00 
3/1/20231/1/202219999Customer A00 
4/1/20231/1/202219999Customer A00 
5/1/20231/1/202219999Customer A00 
6/1/20231/1/202219999Customer A00 
7/1/20231/1/202219999Customer A00 
8/1/20231/1/202219999Customer A00 
9/1/20231/1/202219999Customer A00 
10/1/20231/1/202219999Customer A00 
11/1/20231/1/202219999Customer A00 
12/1/20231/1/202219999Customer A00 
1/1/20241/1/202219999Customer A00 
2/1/20241/1/202219999Customer A00 
3/1/20241/1/202219999Customer A00 
4/1/20241/1/202219999Customer A00 
AntrikshSharma
Super User
Super User

@aakif_xec You should convert that model into star schema, once you get the first order date you can just convert that date into the start of next year by using DATE ( YEAR ( first_order_date ), 1, 1 ) and then compare the dates as you want.

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.