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

dax

i need to convert follwing calculated field WINDOW_SUM((IF [Minimun date 0]>=min(DATEADD('month',-12,[Date]) ) THEN [TR Count] ELSE 0 END),-11,0)/12 as PBI dax code

11 REPLIES 11
MillarJayakumar
Frequent Visitor

can any one convert below tableau ( calulated field) as dax query

WINDOW_SUM((IF [LOOKUP(MIN(([Date])),0)]>=min(DATEADD('month',-12,[Date]) ) THEN [COUNTD([TRID])] ELSE 0 END),-11,0)/12

Result as per tableau 

MillarJayakumar_0-1704787794876.png

result as per pbi ( which is providing incrrect result)

MillarJayakumar_1-1704787845981.png

 

Anonymous
Not applicable

Hi @MillarJayakumar,

You can try to use the following measure formula if helps:

formula =
VAR currDate =
    MIN ( 'Table1'[Date] )
VAR result =
    CALCULATE (
        COUNTROWS ( VALUES ( 'Table1'[TRID] ) ),
        FILTER (
            ALLSELECTED ( 'Table1' ),
            'Table1'[Date]
                >= DATE ( YEAR ( currDate ), MONTH ( currDate ) - 12, DAY ( currDate ) )
                && 'Table1'[Date] <= currDate
        )
    )
RETURN
    result / 12

Regards,

Xiaoxin Sheng

saud968
Super User
Super User

Try this

PBI DAX Code =
CALCULATE(
AVERAGEX(
FILTER(
ALL('YourTable'),
'YourTable'[Minimun date 0] >= MINX(ALL('YourTable'), DATEADD('YourTable'[Date], -12, MONTH))
),
'YourTable'[TR Count]
),
DATEADD('YourTable'[Date], -11, MONTH),
'YourTable'[Date]
) / 12

Replace 'YourTable' with the actual name of your table.

Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!




Hope for COUNTD([TRID]) we can use dax as COUNTROWS(VALUES('YourTableName'[TRID])) could you pls confirm dax for LOOKUP(MIN(([Date])),0)

If you want to get the minimum date from a column named [Date] where the lookup value is 0, you can use the following DAX expression:

LOOKUPVALUE('YourTableName'[Date], 'YourTableName'[YourLookupColumn], 0)
Replace 'YourTableName' with the actual name of your table, and 'YourLookupColumn' with the actual name of the column where you want to find the lookup value of 0.

This DAX expression uses the LOOKUPVALUE function to retrieve the value from the [Date] column where the value in the [YourLookupColumn] is equal to 0.

If you are looking for the minimum date across all rows where the lookup value is 0, you can use the following expression:

CALCULATE(MIN('YourTableName'[Date]), 'YourTableName'[YourLookupColumn] = 0)
Again, replace 'YourTableName' and 'YourLookupColumn' with the actual names of your table and lookup column.

Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!

Its not working can you recheck it once again my code WINDOW_SUM((IF (LOOKUP(MIN(([Date])),0)>=min(DATEADD('month',-12,[Date]) ) THEN COUNTD([TRID]) ELSE 0 END),-11,0)/12

Is there an error you are getting

its not showing any value

Try this 

PBI DAX Code =
CALCULATE(
AVERAGEX(
FILTER(
ALL('YourTable'),
'YourTable'[Minimun date 0] >= MINX(ALL('YourTable'), DATEADD('YourTable'[Date], -12, MONTH))
),
'YourTable'[TR Count]
),
DATEADD('YourTable'[Date], -11, MONTH),
'YourTable'[Date]
) / 12

If this does not work can you share the sample file, and remove sensitive data?

Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!

YourTable'[Minimun date 0]  ITS NOT A Column its a calculated field LOOKUP(MIN(([Date])),0)

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.