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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Replicate Excel logic in DAX

Hi,

 

I would like to replicate in Power BI, preferabily using DAX, the below excel logic:

1) Combining all the rows of a week (Monday-Sunday). The process in excel currently is the following: the user is adding to the Monday's data the new records found on Tuesday, after this is comparing Monday+new Tuesday's data  with the Wednesdey's records and is adding to the Monday+new Tuesday's data the Wednesday's new records   and so one until Sunday (included).

This combined data is then compared with the next  Monday data and what is not found on Monday's records is marked as Outflow. This process is being repetead for all the following weeks and what I want to retrieve is the number of the records marked as Outflows during a certain week, by creating a first column like the one in the sample - Result - in a new DAX column.

 

Thank you,

Melissa

recordWeekWeekDayDateResult - in a new DAX column
12455421Sunday03/15/2020Outflow - is not appearing in the following Monday
12245442Monday03/16/2020 
12245442Tuesday03/17/2020 
12334432Tuesday03/17/2020Outflow - is not appearing in the following Monday
12245442Thurday03/19/2020 
12245472Sunday03/22/2020Outflow - is not appearing in the following Monday
12245443Monday03/23/2020 
12245443Wednesday03/25/2020Outflow - is not appearing in the following Monday
13345554Monday03/30/2020 

 

 

1 ACCEPTED SOLUTION
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

Column = 
VAR x = 
CALCULATE(
    MAX(Sheet1[record]),
    FILTER(
        Sheet1,
        Sheet1[Week] = EARLIER(Sheet1[Week]) + 1  && Sheet1[WeekDay] = "Monday"
    )
)
RETURN
IF(
    Sheet1[record] <> x && Sheet1[WeekDay] <> "Monday",
    "Outflow", BLANK()
)

jjj2.PNG

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

Column = 
VAR x = 
CALCULATE(
    MAX(Sheet1[record]),
    FILTER(
        Sheet1,
        Sheet1[Week] = EARLIER(Sheet1[Week]) + 1  && Sheet1[WeekDay] = "Monday"
    )
)
RETURN
IF(
    Sheet1[record] <> x && Sheet1[WeekDay] <> "Monday",
    "Outflow", BLANK()
)

jjj2.PNG

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Super User
Super User

I am not following this, I do not understand why some rows are marked as Outflow and others are not, like one Tuesday is and one is not and also the Thursday.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler 

 

Hi Greg,

 

Any idea how can I replicate this logic in DAX?

 

Many thanks,

Melisa

Anonymous
Not applicable

Hi @Greg_Deckler 

 

As you can see, that record is found in the next Monday, so it cannot be marked as Outflow.

 

Thank you,

Melisa

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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