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
Ttaylor9870
Helper III
Helper III

Sales before and after if stand is TRUE

Hey All,

 

I've been stuck on the following problem. I'd like to know the amount before and after a customer receives a stand.

 

Logic would be sales after STAND is true based on the Posting DATE

 

See my example table below...

 

CustomerAmountPosting DateItem NoProduct NameStand

A105/01/2023TD01AAATRUE
A206/01/2023REDBBBFALSE
A307/01/2023BLUECCCFALSE
B105/01/2023TD01AAATRUE
B204/01/2023REDBBBFALSE
B307/01/2023BLUECCCFALSE
C104/01/2023TD01AAATRUE
C203/01/2023REDBBBFALSE
C302/01/2023BLUECCCFALSE

 

Many Thanks,

 

Taylor

3 REPLIES 3
v-xiandat-msft
Community Support
Community Support

Hi @Ttaylor9870 ,

Below is my table:

vxiandatmsft_0-1704350661316.png

The following DAX might work for you:

Column = 
VAR A =
CALCULATE(
    MAX('Tabelle1'[Date]),
    FILTER(
        ALL(Tabelle1),
        'Tabelle1'[stand] = True && 'Tabelle1'[Customer_Amount] = EARLIER(Tabelle1[Customer_Amount])
    )
)
RETURN
   IF(Tabelle1[stand] = True , 
   'Tabelle1'[Date],
   A
    )

The final output is shown in the following figure:

vxiandatmsft_1-1704350735884.png

Best Regards,

Xianda Tang

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

Ttaylor9870
Helper III
Helper III

Hey @v-xiandat-msft,

 

See the below expected results...

 

CustomerAmountPosting DateItem NoProduct NameStandStand Posting Date  (Expected Output)
A105/01/2023TD01AAATRUE05/01/2023
A206/01/2023REDBBBFALSE05/01/2023
A307/01/2023BLUECCCFALSE05/01/2023
B105/01/2023TD01AAATRUE05/01/2023
B204/01/2023REDBBBFALSE05/01/2023
B307/01/2023BLUECCCFALSE05/01/2023
C104/01/2023TD01AAATRUE04/01/2023
C203/01/2023REDBBBFALSE04/01/2023
C302/01/2023BLUECCCFALSE04/01/2023

 

The logic would be as follows, DAX or Power Query to....

 

Go through the table to find customer -> Then find the products the customer has bought -> For that specific product if they bought a stand (Stand = TRUE) for that product return the MAX posting Date.

 

So there could be a couple products per customer. The above is just a short example.😊

 

Many Thanks,

 

Taylor

v-xiandat-msft
Community Support
Community Support

Hi @Ttaylor9870 ,

Can you send us the expected result graph, thank you

Best Regards

Xianda Tang

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

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.

Top Solution Authors