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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Tabor
New Member

I have a dax query statement that I don't know how to write, asking for help

DEFINE
    COLUMN DataSource[ym] =
        YEAR ( DataSource[date] ) * 100
            MONTH ( DataSource[date] )
    COLUMN DataSource[day] =
        DAY ( DataSource[date] )
    MEASURE DataSource[Sales] =
        SUM ( DataSource[Count_Orders] )
    MEASURE DataSource[MonthlySales] =
        VAR t0 =
            SUMMARIZECOLUMNS (
                DataSource[shop_id],
                DataSource[shop_name],
                DataSource[date],
                DataSource[ym],
                DataSource[day],
                "@Sales", [Sales]
            )
        VAR dp = [shop_id]
        VAR dp_name = [shop_name]
        VAR ymm = [ym]
        VAR dt = [day]
        VAR filter_table =
            FILTER (
                t0,
                dp = [shop_id]
                    && dp_name = [shop_name]
                    && ymm = [ym]
                    && dt = [day]
                    && [@Sales] <= [Sales]
            )
        VAR result =
            SUMX ( filter_table, [@Sales] )
        RETURN
            result

EVALUATE
SUMMARIZECOLUMNS (
    DataSource[shop_id],
    DataSource[shop_name],
    DataSource[date],
    DataSource[ym],
    DataSource[day],
    "SALE", DataSource[Sales],
    "M_SALE", DataSource[MonthlySales]
)

 

 

The above statement shows an error in DAX-STUDIO, but I don't know how I should build the correct code,

I'm just a beginner, a lot of mistakes, please forgive me, thank you very much!!!

4 REPLIES 4
Tabor
New Member

f641378e1cf35b0fce513e8d5a7110e9_1712710119721_wm.png

tharunkumarRTK
Super User
Super User

@Tabor 

From the initial observation I could see that you used Summarizecolumns in a measure DataSource[MonthlySales], which will fail to execute. Can you share the error message?

 

This is my error message, please help me check, thanks again!

@Tabor 
Error message will be above that line. Please share the pbix if possible

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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