# Convert DAX Calculated Column to a Measure



## brawnystaff (Aug 22, 2019)

Trying to convert a DAX Calculated Column to a Measure with no luck.  Any ideas? See below and attached.  Thanks.


```
=CALCULATE (
    DISTINCTCOUNT ( Table1[Patient ID] ),
    FILTER (
        Table1,
        Table1[TotalTime] > Legend[Start]
            && Table1[TotalTime] <= Legend[End]
    )
)
```

https://drive.google.com/open?id=1qGzT1ryD2tT8Nx63pIFv4pUsGc5ZXggm


----------



## MrVillareal (Aug 29, 2019)

You can try DAX code below:


```
Distinct Count ID:=
VAR TableList = 
    FILTER(
        VALUES(Table1[TotalTime]),
        Table1[TotalTime] > MIN(Legend[Start]) &&
        Table1[TotalTime] <= MAX(Legend[End])
    )
RETURN
    CALCULATE(
        DISTINCTCOUNT(Table1[Patient ID]),
        TableList
    )
```


----------



## brawnystaff (Aug 29, 2019)

Thanks MrVillareal.  It worked!!  Tried using a SUMX expression and just wan't working..this would did..


----------



## MrVillareal (Sep 1, 2019)

brawnystaff said:


> Thanks MrVillareal.  It worked!!  Tried using a SUMX expression and just wan't working..this would did..



Your welcome!


----------



## Ariannabertoni (Mar 29, 2021)

MrVillareal said:


> can you help me with this I need to transform this calculated column into a measure
> CALCULATE(SUM(Table1[Totaltime]) - SUM(Table1[Totaltime2]), Table1[[Weight] <> "5", Table1[[Weight] <> "6")


----------

