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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
sedkimic
Frequent Visitor

DAX Expression works in DAX Studio but fails in Power BI

The below DAX expression returns the expected results in DAX Studio ( a two column table) when connected to a Power BI data model in the Service.  However, when I attempt to use the same logic (the expression is modified at the end to return a scalar value and EVALUATE is removed), I receive these contect error messages as well as this overall error message. 

 

Is there something different between how DAX studio is evaluating this and how Power BI is evaluating it?

sedkimic_0-1677626661633.png

sedkimic_1-1677626785230.png

 

 

******

 EVALUATE
(
    VAR dates =
        SUMMARIZECOLUMNS (
            dimDate[EndOfMonth],
            dimDateMaturity[AdjustedMaturityDate],
            "@diff",
               [a] + [b] - [c]
        )
    VAR filtered =
        FILTER ( dates, [@diff] < 0 )
    VAR indexed =
        INDEX (
            1,
            filtered,
            ORDERBY ( [@diff], DESC ),
            PARTITIONBY ( dimDate[EndOfMonth] )
        )
    RETURN
        SELECTCOLUMNS (
            indexed,
            "Date", dimDate[EndOfMonth],
            "Days", DATEDIFF ( dimDate[EndOfMonth], dimDateMaturity[AdjustedMaturityDate], DAY )
        )
)

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

Please try something like below.

I only wrote for SUMMAIZECOLUMNS part to suggest to change like below.

 


VAR dates =
ADDCOLUMNS (
SUMMARIZE (
YourFactTable,
dimDate[EndOfMonth],
dimDateMaturity[AdjustedMaturityDate]
),
"@diff",
[a] + [b] - [c]
)


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

I tried that and the same issue persists.  Again, it works in DAX studio but it doesn't work in Power BI.  For some reason the indexed variable is not able to reference the filtered variable.

sedkimic_0-1677679269136.png

 

Helpful resources

Announcements
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!

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.