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
mromberg
Frequent Visitor

Flagging New Accounts Based on Prior Ordering

Failry new user to PowerBI and need help with a calculation.  I'm trying to flag new accounts for the current quarter.  First qualfiier is order in Current Quarter>0.  Second qualifier is no orders IN THE SAME TERRITORY, for the Prior Quarter.  With these two criteria met this would qualify as a New Current Qtr Account. If an account has an order in the same territory for both Prior Quarter and Current Quarter this is NOT a new account.  Need help with the 'New Current Qtr Account' column.  Data example below.  Thanks!

 

Account #TerritoryTime PeriodOrder CountNew Current Qtr Account
123San DiegoCurrent Quarter1Y
123Los AngelesPrior Quarter1 
321MiamiCurrent Quarter1N
321MiamiPrior Quarter1 
543Kansas CityCurrent Quarter1Y
1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @mromberg 

Try this, and please check the sample file attached below

Column = 
VAR _isnew =
    IF (
        CALCULATE (
            COUNTROWS ( 'Table' ),
            FILTER (
                'Table',
                'Table'[Account #] = EARLIER ( 'Table'[Account #] )
                    && 'Table'[Territory] = EARLIER ( 'Table'[Territory] )
                    && 'Table'[Time Period] = "Prior Quarter"
            )
        ) > 0,
        "N",
        "Y"
    )
RETURN
    IF ( 'Table'[Time Period] = "Current Quarter", _isnew, BLANK () )

vxiaotang_0-1648544156495.png

Best Regards,

Community Support Team _Tang

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

View solution in original post

3 REPLIES 3
v-xiaotang
Community Support
Community Support

Hi @mromberg 

Try this, and please check the sample file attached below

Column = 
VAR _isnew =
    IF (
        CALCULATE (
            COUNTROWS ( 'Table' ),
            FILTER (
                'Table',
                'Table'[Account #] = EARLIER ( 'Table'[Account #] )
                    && 'Table'[Territory] = EARLIER ( 'Table'[Territory] )
                    && 'Table'[Time Period] = "Prior Quarter"
            )
        ) > 0,
        "N",
        "Y"
    )
RETURN
    IF ( 'Table'[Time Period] = "Current Quarter", _isnew, BLANK () )

vxiaotang_0-1648544156495.png

Best Regards,

Community Support Team _Tang

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

mromberg
Frequent Visitor

Oh so close.!  However, I did not represent my data correctly in the example I gave.  There is another scenario where account has current orders, no orders last quarter and HAS orders two quarters ago.  In this case we would want to call this a new account.  See Seattle.

 

mromberg_0-1648227540659.png

 

amitchandak
Super User
Super User

@mromberg , a new column

 

New Column =
var _cnt = countx(filter(Table, [Account#] = earlier([Account#]) && [Territory] = earlier([Territory]) ), [Account#])
return
Switch(True(),
[Time Period] = "Current Quarter" && _cnt >1, "N",
[Time Period] = "Current Quarter" && _cnt = 1,"Y",
blank()
)

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.