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
AlessandroFossi
New Member

Euclidean Distance measure with DAX

Dear Community, 

 

I found myself stuck with this formula in DAX, seems ok because the editor does not throws an error but the measure is always zero in power BI charts. 

The measure is intended to calculate euclidean distance between two multi-variable time-series that you find in this table exemple:

 

FechaAnoDiaMesppOriginal Without SuffixSuffixDatetimehours
1/1/2018 1:002018110.2932URAN_AggrPROP1/1/2018 1:001:00
1/1/2018 1:002018110.0147Net_importsPROP_OBS1/1/2018 1:001:00
1/1/2018 1:002018110.0016NGAS_CCGT_new_AggrPROP1/1/2018 1:001:00
1/1/2018 1:002018110.0003SUN__PV____GenericPROP1/1/2018 1:001:00
1/1/2018 1:002018110.0003SUN__PV____GenericPROP_OBS1/1/2018 1:001:00
1/1/2018 1:002018110SUN__CSP___GenericPROP1/1/2018 1:001:00
1/1/2018 1:002018110.5017WIND_ONSHO_GenericPROP1/1/2018 1:001:00
1/1/2018 1:002018110.0447WATR_ROR___AggrPROP1/1/2018 1:001:00
1/1/2018 1:002018110.0147WATR_STO___AggrPROP1/1/2018 1:001:00
1/1/2018 1:002018110.102NRES_AggrPROP1/1/2018 1:001:00
1/1/2018 1:002018110.0148BIOM_AggrPROP_OBS1/1/2018 1:001:00
1/1/2018 1:002018110.0157WAST_AggrPROP1/1/2018 1:001:00
1/1/2018 1:002018110.0155BIOM_AggrPROP1/1/2018 1:001:00
1/1/2018 1:002018110WATR_PSP___AggrPROP1/1/2018 1:001:00
1/1/2018 1:002018110.0971NRES_AggrPROP_OBS1/1/2018 1:001:00
1/1/2018 1:002018110.0101COAL_AggrPROP_OBS1/1/2018 1:001:00
1/1/2018 1:002018110.0149WAST_AggrPROP_OBS1/1/2018 1:001:00
1/1/2018 1:002018110.0421WATR_STO___AggrPROP_OBS1/1/2018 1:001:00
1/1/2018 1:002018110.0106COAL_AggrPROP1/1/2018 1:001:00
1/1/2018 1:002018110.2856URAN_AggrPROP_OBS1/1/2018 1:001:00
1/1/2018 1:002018110Net_importsPROP1/1/2018 1:001:00
1/1/2018 1:002018110.4778WIND_ONSHO_GenericPROP_OBS1/1/2018 1:001:00
1/1/2018 1:002018110.0425WATR_ROR___AggrPROP_OBS1/1/2018 1:001:00
1/1/2018 1:002018110NGAS_CCGT_new_AggrPROP_OBS1/1/2018 1:001:00
1/1/2018 1:002018110WATR_PSP___AggrPROP_OBS1/1/2018 1:001:00
1/1/2018 1:002018110.0001SUN__CSP___GenericPROP_OBS1/1/2018 1:001:00

 

 

and the DAX measure is this: 

 

EuclideanDistance =
VAR SelectedSuffix = "PROP"  -- Replace with the desired suffix ("PROP" or "OBS")
VAR Series1Values =
    ADDCOLUMNS(
        SUMMARIZE(
            FILTER('df (2)', 'df (2)'[Suffix] = SelectedSuffix),
            'df (2)'[Datetime],
            'df (2)'[Original Without Suffix]
        ),
        "pp_Series1", CALCULATE(MAX('df (2)'[pp]))
    )
VAR Series2Values =
    ADDCOLUMNS(
        SUMMARIZE(
            FILTER('df (2)', 'df (2)'[Suffix] <> SelectedSuffix),
            'df (2)'[Datetime],
            'df (2)'[Original Without Suffix]
        ),
        "pp_Series2", CALCULATE(MAX('df (2)'[pp]))
    )
VAR IntersectedValues =
    NATURALINNERJOIN(Series1Values, Series2Values)

VAR SumOfSquares =
    SUMX(
        IntersectedValues,
        POWER([pp_Series1] - [pp_Series2], 2)
    )
VAR EuclideanDistance =
    SQRT(SumOfSquares)
RETURN
    EuclideanDistance
 
 
Any idea on how to solve this?
 
Thanks in advance
 
Alessandro
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @AlessandroFossi ,

I looked at your DAX code and copied your values into Power BI and found the problem to be the following.

For this part of the image below, he needs to recreate two new tables.

vyilongmsft_0-1719972396290.pngvyilongmsft_1-1719972427326.png

vyilongmsft_2-1719972493283.png

You are using the NATURALINNERJOIN function, the join function 'NATURALINNERJOIN' requires at-least one common join column. So I think you can modify your code a bit.

 

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @AlessandroFossi ,

I looked at your DAX code and copied your values into Power BI and found the problem to be the following.

For this part of the image below, he needs to recreate two new tables.

vyilongmsft_0-1719972396290.pngvyilongmsft_1-1719972427326.png

vyilongmsft_2-1719972493283.png

You are using the NATURALINNERJOIN function, the join function 'NATURALINNERJOIN' requires at-least one common join column. So I think you can modify your code a bit.

 

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.

Top Solution Authors
Top Kudoed Authors