Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Days calculation from slicer

Hi,

I want to calculate days from the selected month, it shold be 61 days. How I get this result.

I am not using date or calander table, slicer dates come from fact table.

I tried following:

days =

var MINval = CALCULATE(MIN('Fact'[Date]),ALLSELECTED(''Fact'[Date]))
var Maxval = CALCULATE(Max('Fact'[Date]) ,ALLSELECTED('Fact'[Date]))
return
DATEDIFF(MINval,Maxval,DAY)

 

 

Thank you.

 

 

  • Anonymous Try:

    days =
    var MINval = MIN('Fact'[Date])
    var Maxval = Max('Fact'[Date])
    var result = ( MaxVal - MINval ) * 1.
    return
    result

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Anonymous Try:

    days =
    var MINval = MIN('Fact'[Date])
    var Maxval = Max('Fact'[Date])
    var result = ( MaxVal - MINval ) * 1.
    return
    result
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks Greg, but it gives days count from begining of fact date till end date.

      Its not giving days between selected months. 

       

      • Greg_Deckler's avatar
        Greg_Deckler
        Icon for Community Champion rankCommunity Champion

        Anonymous Difficult to say unless maybe your slicer is not filtering whatever visualization you are displaying the measure in. Or, are you creating this as a calculated column? If a calculated column, that won't work as those are not interactive. You have to create it as a measure. I mocked up a PBIX file that demonstrates. It is attached below signature.