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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
Super User
Super User

@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!:
Power BI Cookbook Third Edition (Color)

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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