Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Single Slicer for Period

Hi All,

 

I have two dates, From and To.

 

I have created one Dimension Date table for slicer.

 

Objective is to calculate count if slicer date lye between from and to date.

 

Here is the Dax for for Count, Its working fine if I have From and To Date available in Grid, but when i remove these columns from Grid so i have wrong count.

 

SR Count =

var flag =
IF (
SELECTEDVALUE ( 'CompanyInvolvment'[SrFromDate] ) <= MAX ( DimDate[FullDateAlternateKey] )
&& SELECTEDVALUE ( 'CompanyInvolvment'[SrToDate] ) >= MIN ( DimDate[FullDateAlternateKey] )
,
1,0
)
var SRCount =
IF (
flag = 1, CALCULATE(DISTINCTCOUNT('CompanyInvolvment'[SR_Number])) + 0,0

)
return CONVERT(SRCount,INTEGER)
 
Current selection in slicer is Sep,22. This is correct result when i have dates in Grid
farhadidrees_0-1666273024289.png

 

But when i remove Dates from Grid so it becomes 0 There should be Total 3 Count.

farhadidrees_1-1666273087756.png

This is the issue, i dont want to show Dates in grid.

 

Any suggestion?

 

Regards,

 

 
2 REPLIES 2
Jayee
Responsive Resident
Responsive Resident

Hi @Anonymous 

 

try below DAX if the field SR_Number unique to table CompanyInvolvment then it works otherwise need to modify the DAX to solve your requirement.

SR Count =
COUNTX (
CompanyInvolvment,
IF (
SELECTEDVALUE ( 'CompanyInvolvment'[SrFromDate] )
<= MAX ( DimDate[FullDateAlternateKey] )
&& SELECTEDVALUE ( 'CompanyInvolvment'[SrToDate] )
>= MIN ( DimDate[FullDateAlternateKey] ),
1,
0
)
)

 

Anonymous
Not applicable

Hi Jayee, 

 

Thanks for response.

I modify the DAX and having Unique SR Numbers but still it is having wrong counting as shown below.

Filter selection is septembr,2022 but it is counting some other values as well which is not lying between this date.

 

farhadidrees_1-1666328686878.png

Any idea?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.