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

How to make calculation for customers with new orders

Hello, i want to make a Dax formula where i have as result a % Sales this season 24 versus last season 23. And in this calculation i only want calculate this when a customer has already places SaleOrders for this season 24. 

I have an example in excel attached: 

 

SalesOrder Table

Bart_0-1706200779780.png

 

You see that Customer C don't have new orders for season 24

In the calculation below i expect an outcome of 114% ( = 8/7)

 

Bart_1-1706200851877.png

 

 

1 ACCEPTED SOLUTION
Bart
Frequent Visitor

Thank you for this great solution @Ashish_Mathur , I used both 👍🏻

View solution in original post

4 REPLIES 4
Bart
Frequent Visitor

Thank you for this great solution @Ashish_Mathur , I used both 👍🏻

Ashish_Mathur
Super User
Super User

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1706233366026.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
eliasayyy
Super User
Super User

Hello @Bart ,

create a flag column

Flag = 
VAR _on = 'Table'[OrderNb]
VAR _name = 'Table'[Name]
VAR _season = 'Table'[Season]

RETURN 
IF(
    COUNTROWS(
        FILTER(
            'Table',
            'Table'[OrderNb] <> _on &&
            'Table'[Name] = _name &&
            'Table'[Season] <> _season
        )
    ) > 0,
    1,
    0
)

 

this measure will count where each client have multipl sales from different seasons,

Result

eliasayyy_0-1706203304209.png



now just create a simple dax measure

Varriance = 
VAR _s23 = CALCULATE(SUM('Table'[Amount]),'Table'[Season] = 23 && 'Table'[Flag] = 1)
VAR _s24 = CALCULATE(SUM('Table'[Amount]),'Table'[Season] = 24 && 'Table'[Flag] = 1)
RETURN
DIVIDE(
    _s24,
    _s23
)

 

results

eliasayyy_1-1706203346670.png

 

Hi, the result is ok, thank you for the quick reply!

But i have a tabel with 30k rows, and when i refresh i get the error : there is not enough memory.

I guess this is due to this new column and measure. 

Do you have a solution for this?

 

regards, Bart

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.