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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Comparing One measure against another measure

Hello there,

For the below ID, start & end dates, there are 2 measures in place to get the active IDs until week in context & previous week in context - based on Start & end dates.

 

What is the best way to compare the IDs resulted by the 2 measures to arrive at the third measure which identifies the IDs active in previous week context but not in current week context?

 

IDStartEnd 
A01/01/202102/01/2021 
B01/01/202106/01/2021 
C06/01/202107/01/2021 
A11/01/202112/01/2021 
    
    
Date   
DateWeekDay  
01/01/20212021-1Fri 
02/01/20212021-1Sat 
03/01/20212021-1Sun 
04/01/20212021-2Mon 
05/01/20212021-2Tue 
06/01/20212021-2Wed 
07/01/20212021-2Thu 
08/01/20212021-2Fri 
09/01/20212021-2Sat 
10/01/20212021-2Sun 
11/01/20212021-3Mon 
    
Result by Week  
WeekMeasure 1 - Active ID count until the weekMeasure 2 - Active ID count until  previous weekMeasure 3 - Active in previous but inactive in current week
2021-12  
2021-222 
2021-312 

 

Appreciate any suggestion.

 

Regards,

Pravallika

4 REPLIES 4
Anonymous
Not applicable

Thanks again for taking time to respond.

I do not want to use exclude & rather use my two measures to work in a way to find out the inactive ones. This is because, the result using exclude cannot be sliced or diced with other filters.

 

This is the reason why I used the title of comparing one measure against another. 
Is there any other way you can think of?

 

Cheers,

Pravallika

Anonymous
Not applicable

Hello Jihwan,

 

Thanks for responding, I tried using EXCEPT() earlier too. There is an active relationship between the tables Date & IDs on Start_Date.

Even with your example, when you add a relationship the measure doesn't calculate. 
Is there any other workaround you can think of?

 

 

pravallikasri_0-1620837409262.png

 

 

pravallikasri_1-1620837424457.png

 

Thanks!

Hi, @Anonymous 

Thank you for your feedback.

In my case, if there are more than two date-related columns in a fact table, I generally create inactive relationships and use the USERELATIONSHIP function later, if I want to filter by the dim-date table. Or, I generally do not create relationships and use TREATAS function later, if I want to filter by the dim-date table.

 

If, in your case, you have an active relationship with startdate, then you can simply remove the filter inside the measure. By using ALL can help to remove the filter.

I have amended a relationship, same as your suggestion, and also amended all measures in the sample pbix file's link down below. Please check.

 

https://www.dropbox.com/s/lm65er2k95xe4d1/pravallikasri.pbix?dl=0 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please check the below picture and the sample pbix file's link down below.

All measures are in the sample pbix file.

 

Picture2.png

 

Active Previous & Inactive Current Week ID Count =
VAR mindatecurrentweek =
MIN ( Dates[Date] )
VAR idlistprevious =
CALCULATETABLE (
VALUES ( IDs ),
FILTER (
IDs,
IDs[Start] <= mindatecurrentweek - 1
&& IDs[End] >= mindatecurrentweek - 7
)
)
VAR idlistcurrent =
CALCULATETABLE (
VALUES ( IDs ),
FILTER (
IDs,
IDs[Start] <= MAX ( Dates[Date] )
&& IDs[End] >= MIN ( Dates[Date] )
)
)
RETURN
COUNTROWS ( EXCEPT ( idlistprevious, idlistcurrent ) )
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors