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
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
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.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.