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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Pk8524
Helper I
Helper I

Need help with getting wrong data in the graph

I am creating a dax measure called: "New Customers Sales Cumulative" which creates on the go a table

 CustomerOrdersFinal which looks like this:
012.JPG
In the last line of code of this measure I refer to column Rolling, but when I am using this measure in the graph
it seems it takes data from SalesByYear:
 
011.JPG
Why despite the fact that I am referring to rolling column, the graph takes data from SalesByYear?
 
2 REPLIES 2
Anonymous
Not applicable

Hi @Pk8524 ,

 

Power BI visuals automatically aggregate and display data based on the available context and dimensions used in the visual.

 

The EARLIER function is context-dependent and may not work as expected in the function.

 

An alternative available is to replace the fields in the chart with Year and Rolling from the New Customers Sales table.

vhuijieymsft_0-1717642151494.png

 

The visual will look like this:

vhuijieymsft_1-1717642151496.png

 

If you have any other questions please feel free to contact me.

 

The pbix file is attached.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Hi!

The issue with your solution is that I need to make it dynamically (not static).

 

001.JPG

By changing the parametr, the graph should be updated. This is why the tables are created 'on the go' in the measure using dax. I have made the dax measure a little bit simplier and now it looks as follows:

New Customers Sales **bleep** = 
VAR CustomerOrders = 
    SUMMARIZE(
        Orders,
        Orders[Klient_Nazwa],
        Orders[Data Zamówienia],
        "Year", YEAR(Orders[Data Zamówienia]),
        "TotalSales", SUM(Orders[Sprzedaż]),
        "TotalOrdersByClient", CALCULATE(DISTINCTCOUNT(Orders[ ID Zamówienia]), ALLEXCEPT(Orders, Orders[Klient_Nazwa]))
    )
	

Var CustomerOrdersFiltered = 
    FILTER(
        CustomerOrders, [TotalOrdersByClient] <= 'Customer Segmentation 2'[Customer Segmentation 2 Value])

Var CustomerOrdersFilteredGrouped = 
    GROUPBY(
        CustomerOrdersFiltered, [Year], 
        "SalesbyYear", SUMX(CURRENTGROUP(), [TotalSales]))

Var CustomerOrdersFinal = 
    ADDCOLUMNS(
        CustomerOrdersFilteredGrouped,
        "Rolling", SUMX(
            FILTER(
                CustomerOrdersFilteredGrouped,
                [Year] <= EARLIER([Year])
            ),
            [SalesbyYear]
        )
    )

Return SUMX(CustomerOrdersFinal, [Rolling])

 
As the issue is with EARLIER function how I can replace it in this context in order to have Rolling sum for all previous years? 

 

Updated file: https://drive.google.com/file/d/1ohuvV1ty35QdRZ9be5yZBf4Zn9GYsM7i/view?usp=sharing 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.