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
AviramWeiss
Helper I
Helper I

Returning values on slicer bounds

Hello all,

This is a basic question, but I wasn't able to solve it on my own or find a working solution.

I have a table containing date, name and value:

DateNameValue
Nov 1, 2022AAA20
Nov 2, 2022AAA30
Dec 1, 2022AAA40
Nov 5, 2022BBB10

 

I also have a date-period slicer, based on the same table. Let's say I slice Nov 1-30, 2022.

 

I want to show a result grid, with name, sum(value), value @ slicer minimum (in my example Nov 1) and value @ slicer maximum (Nov 30). If values are missing at these particular dates, show either 0 or blank (I don't care):

NameTotalStart valueEnd value
AAA50200 (Or Blank)
BBB100 (Or Blank)0 (Or Blank)

 

Obviously, I don't know the slicer choice in advance. It's up to the user to pick...

Tried to create measures with min/max using ALLSELECTED or KEEPFILTERS, and then add columns "First" and "Last" to the table, which are populated only when date=measure. Didn't work.

Ideas would be warmly welcomed.

1 ACCEPTED SOLUTION

hi @AviramWeiss 

Aha, the Date column of the slicer shall come from an independent Date Table with this code:

DateTable = CALENDAR(MIN(TableName[Date]), MAX(TableName[Date]))
 
And change the code for the measures to:
StartValue =
VAR MinDate = MIN (DateTable[Date])
RETURN
CALCULATE(
    SUM(TableName[Value]),
    TableName[Date] = MinDate
)
EndValue =
VAR MaxDate = MAX (DateTable[Date])
RETURN
CALCULATE(
    SUM(TableName[Value]),
    TableName[Date] = MaxDate
)
Total =
VAR MinDate = MIN (DateTable[Date])
VAR MaxDate = MAX (DateTable[Date])
RETURN
CALCULATE(
    SUM(TableName[Value]),
    TableName[Date] >= MinDate
         &&TableName[Date] <= MaxDate
)
i tried and it now worked like this:
FreemanZ_0-1670836676614.png
 

View solution in original post

4 REPLIES 4
FreemanZ
Super User
Super User

hi @AviramWeiss 

try to plot a table visual of three measures with the code below:

try like
 
StartValue =
VAR MinDate = MIN (TableName[Date])
RETURN
CALCULATE(
    SUM(TableName[Value]),
    TableName[Date] = MinDate
)
 
EndValue =
VAR MaxDate = MAX (TableName[Date])
RETURN
CALCULATE(
    SUM(TableName[Value]),
    TableName[Date] = MaxDate
)
 
Total =
VAR MinDate = MIN (TableName[Date])
VAR MaxDate = MAX (TableName[Date])
RETURN
CALCULATE(
    SUM(TableName[Value]),
    TableName[Date] >= MinDate
         &&TableName[Date] <= MaxDate
)

Thank you, FreemanZ, for the quick and thorough response.
I have tried your solution, but like all previous ones, it takes a "personal" max for every category.

Thus, If I pick a min/max date that has no instance, the measure takes the first/last date within the selected range, and not the exact first/last date.
Here's the data I entered again (all dates are dd/mm/yyyy format):

AviramWeiss_0-1670829143530.png

When I pick Nov 2-7, I want to get for AAA startValue=30 and endValue=0, becuase it has no records at Nov 7. These are the results I got:

AviramWeiss_1-1670829684259.png

 

Thank you very much again.

 

 

hi @AviramWeiss 

Aha, the Date column of the slicer shall come from an independent Date Table with this code:

DateTable = CALENDAR(MIN(TableName[Date]), MAX(TableName[Date]))
 
And change the code for the measures to:
StartValue =
VAR MinDate = MIN (DateTable[Date])
RETURN
CALCULATE(
    SUM(TableName[Value]),
    TableName[Date] = MinDate
)
EndValue =
VAR MaxDate = MAX (DateTable[Date])
RETURN
CALCULATE(
    SUM(TableName[Value]),
    TableName[Date] = MaxDate
)
Total =
VAR MinDate = MIN (DateTable[Date])
VAR MaxDate = MAX (DateTable[Date])
RETURN
CALCULATE(
    SUM(TableName[Value]),
    TableName[Date] >= MinDate
         &&TableName[Date] <= MaxDate
)
i tried and it now worked like this:
FreemanZ_0-1670836676614.png
 

Works perfectly now. Thank you very much.

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.