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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
u201600699
New Member

Dax Formula

Hi  im new in power bi. I hava a database with sales and incomes,  columns are de date of process, we evaluate every month the sales of the month,  im tryng to get sales from three months ago and evaluate the persistance of six values over incomes. like the image

i hope someone can help me

 

 

 

 

cob.JPG2.JPG

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @u201600699,

Did you mean to get values from three month ago? If that is the case, you can extract the current date as variable to get the previous value based on current category groups.

3M Ago =
VAR currDate =
    MAX ( Calendar[Date] )
RETURN
    CALCULATE (
        SUM ( Table[Value] ),
        FILTER (
            ALLSELECTED ( Table ),
            [Date]
                = DATE ( YEAR ( currDate ), MONTH ( currDate ) - 3, DAY ( currDate ) )
        ),
        VALUES ( Table[concepto] )
    )

I’m not so clear how the persistence of six values calculated, here is the measure formula to get the difference between current three month ago value and rolling six month fact value averages, you can try it if help:

Diff =
VAR currDate =
    MAX ( Calendar[Date] )
VAR threeMonthAgo =
    CALCULATE (
        SUM ( Table[Value] ),
        FILTER (
            ALLSELECTED ( Table ),
            [Date]
                = DATE ( YEAR ( currDate ), MONTH ( currDate ) - 3, DAY ( currDate ) )
        ),
        VALUES ( Table[concepto] )
    )
VAR summary =
    SUMMARIZE (
        FILTER (
            ALLSELECTED ( 'Table' ),
            [Date]
                >= DATE ( YEAR ( currDate ), MONTH ( currDate ) - 6, DAY ( currDate )
                    && [Date] <= currDate )
        ),
        [Date],
        [concepto],
        "current Value", SUM ( 'Table'[Value] )
    )
VAR AVG =
    AVERAGEX ( summary, [current Value] )
RETURN
    DIVIDE ( threeMonthAgo - AVG, AVG )

Regards,

Xiaoxin Sheng

View solution in original post

2 REPLIES 2
devanshi
Helper V
Helper V

MonthlySales = CALCULATE( SUM('Sales'[Income]),
                           DATESINPERIOD('Sales'[Date of Process], LASTDATE('Sales'[Date of Process]), -1, MONTH)
                           )
Persistence = IF( RANKX(ALL('Sales'[Date of Process]), 'Sales'[Date of Process], , ASC, Dense) > 5,
                                      IF( COUNTROWS( FILTER(
                                             TOPN(6, ALL('Sales'[Date of Process]), 'Sales'[Date of Process], ASC, Dense),                                                                                 'Sales'[Income] = EARLIER('Sales'[Income]) ) ) = 6,
                                                       "Persistent", "Not Persistent" ),
                                             BLANK()
)


Anonymous
Not applicable

Hi @u201600699,

Did you mean to get values from three month ago? If that is the case, you can extract the current date as variable to get the previous value based on current category groups.

3M Ago =
VAR currDate =
    MAX ( Calendar[Date] )
RETURN
    CALCULATE (
        SUM ( Table[Value] ),
        FILTER (
            ALLSELECTED ( Table ),
            [Date]
                = DATE ( YEAR ( currDate ), MONTH ( currDate ) - 3, DAY ( currDate ) )
        ),
        VALUES ( Table[concepto] )
    )

I’m not so clear how the persistence of six values calculated, here is the measure formula to get the difference between current three month ago value and rolling six month fact value averages, you can try it if help:

Diff =
VAR currDate =
    MAX ( Calendar[Date] )
VAR threeMonthAgo =
    CALCULATE (
        SUM ( Table[Value] ),
        FILTER (
            ALLSELECTED ( Table ),
            [Date]
                = DATE ( YEAR ( currDate ), MONTH ( currDate ) - 3, DAY ( currDate ) )
        ),
        VALUES ( Table[concepto] )
    )
VAR summary =
    SUMMARIZE (
        FILTER (
            ALLSELECTED ( 'Table' ),
            [Date]
                >= DATE ( YEAR ( currDate ), MONTH ( currDate ) - 6, DAY ( currDate )
                    && [Date] <= currDate )
        ),
        [Date],
        [concepto],
        "current Value", SUM ( 'Table'[Value] )
    )
VAR AVG =
    AVERAGEX ( summary, [current Value] )
RETURN
    DIVIDE ( threeMonthAgo - AVG, AVG )

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.