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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

Top Kudoed Authors