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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

Count a value as 1 when both date from different columns not null

Hi,

I'm cretaing a conditional measure that count events from two diffrent columns that are related by a key .

the date slicer is coming from a relationship table .

I want to count them 1 when both date together exist in the time range from the date slicer .

if only one leg exist then count them as 0  .events are related .

how do you create such measure including userelationship() to the date table 

Thank you 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous ,
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

I may use an independent date table and check both are in range.

 

Even if one joined I can force between on another date

 

//Date 1 joined with and active , pushing filter to date 2
new measure =
var _max = maxx(allselected(Date),Date[Date])
var _min = mainx(allselected(Date),Date[Date])
return
calculate( sum(Table[Value]), filter('Table', 'Table'[Date2] >=_min && 'Table'[Date2] <=_max))

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thank you ! The only diffrence I used CountAX instead of SUM()

amitchandak
Super User
Super User

@Anonymous ,
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

I may use an independent date table and check both are in range.

 

Even if one joined I can force between on another date

 

//Date 1 joined with and active , pushing filter to date 2
new measure =
var _max = maxx(allselected(Date),Date[Date])
var _min = mainx(allselected(Date),Date[Date])
return
calculate( sum(Table[Value]), filter('Table', 'Table'[Date2] >=_min && 'Table'[Date2] <=_max))

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors