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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
chavanr
Resolver I
Resolver I

Add inactive date to a measure.

Hi there,

 

I have a requirement to add inactive date to a measure.

 

Please see below sample data for Table : Test

chavanr_0-1635452821067.png

 

 

So here my "Added Date" is used to create relationship between the calendar table & Test

 

I need to get the count of occupancies by month year upto 15th date of each month for which i am using the below measure.

 

measure=

Var _max = EOMONTH(MAXX(ALLSELECTED('Calendar'),'Calendar'[Date]),-1)+15

return

CALCULATE(SUM(TCC_Kerbside[Occupancies]),DATESYTD('Calendar'[Date]),'Calendar'[Date]<= _max)

 

Now i want to remove the occupancies for which there is inactive date.

e.g. 22 occupancies which were added on 01/07/2021 but became inactive on 21/09/2021 .

and 8 occupancies became inactive on 08/10/2021.

so when a user select october month in the slicer it should do (58594 -(22 +8)) because my reporting month is upto 15th of each month. 

 

Hope this is helpful.

 

 

1 ACCEPTED SOLUTION

Hi @v-rongtiep-msft 

 

I created a variable for inactive 

Occupancies =
Var _max = EOMONTH(MAXX(ALLSELECTED('Calendar'),'Calendar'[Date]),-1)+15
Var _cnt_active =
CALCULATE(SUM(Test[Occupancies]),DATESYTD('Calendar'[Date]),
'Calendar'[Date] <= _max)
Var _cnt_active_return = IF(ISBLANK(_cnt_active),0,_cnt_active)

Var _cnt_inactive =
CALCULATE(SUM(Test[Occupancies]),DATESYTD('Calendar'[Date]),
'Test'[InactiveDate] <= _max, Test[InactiveDate] <> BLANK () )
Var _cnt_inactive_return = IF(ISBLANK(_cnt_inactive),0,_cnt_inactive)

return _cnt_active_return - _cnt_inactive_return

View solution in original post

5 REPLIES 5
v-rongtiep-msft
Community Support
Community Support

Hi @chavanr 

Please provide some data and conditions and why the day is inactive day.

 

Best Regards

Community Support Team _ polly

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-rongtiep-msft 

 

I created a variable for inactive 

Occupancies =
Var _max = EOMONTH(MAXX(ALLSELECTED('Calendar'),'Calendar'[Date]),-1)+15
Var _cnt_active =
CALCULATE(SUM(Test[Occupancies]),DATESYTD('Calendar'[Date]),
'Calendar'[Date] <= _max)
Var _cnt_active_return = IF(ISBLANK(_cnt_active),0,_cnt_active)

Var _cnt_inactive =
CALCULATE(SUM(Test[Occupancies]),DATESYTD('Calendar'[Date]),
'Test'[InactiveDate] <= _max, Test[InactiveDate] <> BLANK () )
Var _cnt_inactive_return = IF(ISBLANK(_cnt_inactive),0,_cnt_inactive)

return _cnt_active_return - _cnt_inactive_return
Greg_Deckler
Super User
Super User

@chavanr Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
vigneshahob
Frequent Visitor

Have you tried the it as values? and used not in ?

&& NOT ( Date ) IN Inactive column}

 

vigneshahob
Frequent Visitor

I'm a newbie, have you tried adding one more condition to the filter within calculate function?

 

CALCULATE(SUM(TCC_Kerbside[Occupancies]),DATESYTD('Calendar'[Date]),'Calendar'[Date]<= _max && 'Calendar'[Date] >Inactive_date) ?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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