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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

changes month over month

 

 

Hello, i am having trouble with the following data set.

 

I have data that is organized in the following way.

 

Program Num

active month

a

1/1/2017

a

2/1/2017

a

3/1/2017

a

4/1/2017

b

5/1/2017

b

6/1/2017

c

1/1/2017

c

2/1/2017

c

3/1/2017

c

4/1/2017

c

5/1/2017

c

6/1/2017

 

Throughout this data, i have 2 unique program num's active at any time.  So if i trend by Distinct program num, i get the value of 2 from Jan-Jun.  No problem here.  This issue is I also need to show...

 

  1. in May, B appeared on the list (gains)
  2. in May, A was disappeared from the list. (losses)

 

This needs to happen in DAX as there are multiple dimensions the users need to select to understand the gains, losses and overall change in counts


I was able to accomplish displaying the values based on the data model, but i cannot figure out how to need to trend the gains/losses.

 

Any ideas?

6 REPLIES 6
Phil_Seamark
Microsoft Employee
Microsoft Employee

HI @Anonymous

 

Do you have an idea on your desired output?  I'm not clear from your post, what you are after. 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

Here would be the desired results, so they i could graph this.

 

if you look at the data from the original post, you can interpret it as this...

- program a is active from Jan-Apr, was new in Jan and lost in May (i.e. Apr was the last active month)

- program b is active from May-Jun, was new in Apr and lost in July (i.e. Jun was the last active month(

- program c is active from Jan-Jun, was new in Jan and lost in July (i.e. Jun was the last active month(

 active programsnew programslost programs
1/1/2017220
2/1/2017200
3/1/2017200
4/1/2017200
5/1/2017211
6/1/201720 0
7/1/2017002

@Anonymous

 

Lets try with this 2 measures:

 

New Programs =
SUMX (
    SUMMARIZE (
        Table1;
        Table1[Program Num];
        "New"; IF (
            CALCULATE (
                MIN ( Table1[Active Month] );
                ALLEXCEPT ( Table1; Table1[Program Num] )
            )
                = SELECTEDVALUE ( ActiveMonths[ActiveMonth] );
            1;
            0
        )
    );
    [New]
)
Lost Programs =
SUMX (
    SUMMARIZE (
        Table1;
        Table1[Program Num];
        "Lost"; IF (
            CALCULATE (
                MAX ( Table1[Active Month] );
                ALLEXCEPT ( Table1; Table1[Program Num] )
            )
                = EDATE ( SELECTEDVALUE ( ActiveMonths[ActiveMonth] ); -1 );
            1;
            0
        )
    );
    [Lost]
)

Assuming you have a table with the ActiveMonths.

Amonth.png

 

And a Visual like:

 

Amonth2.png

Regards

 

Victor




Lima - Peru
Anonymous
Not applicable

Victor,


Thank you for your help.  I have 2 follow up questions.

 

1. I can't seem to get the "lost" DAX to work.  It is producing all zeroes of each month.  Am i missing something?

2. I got the "new" DAX to work, but with 1 issue.  If a program is active, then is lost, and then months later is active again, we want to count that as new again.  for example, in the original data set, say you add a new row for program "A" with an active month in August 2017...it doesn't acknowledge August as a new date.

 

Thank you for your help so far.  This is a huge help.

Anonymous
Not applicable

Victor,

 

I figured out the problem with the lost accounts.  The "EDATE" function should not be applied.

 

so my only issue at the moment is if there 1 program is "new" or "lost" multiple times.  

HI @Anonymous

 

I got pretty close with the following two calculated meaures

 

New Programs = 
VAR ThisMonth =SELECTCOLUMNS(FILTER('Table','Table'[active month] = MAX('Table'[active month])),"P",[Program Num]) 
VAR LastMonth= SELECTCOLUMNS(FILTER(ALL('Table'),'Table'[active month] = EDATE(MAX('Table'[active month]),-1)),"P",[Program Num])
RETURN COUNTROWS(EXCEPT(ThisMonth,LastMonth))+0

and

 

 

Lost Programs = 
VAR ThisMonth =SELECTCOLUMNS(FILTER('Table','Table'[active month] = MAX('Table'[active month])),"P",[Program Num]) 
VAR NextMonth1= SELECTCOLUMNS(FILTER(ALL('Table'),'Table'[active month] = EDATE(MAX('Table'[active month]),-1)),"P",[Program Num])
RETURN COUNTROWS(EXCEPT(NextMonth1,ThisMonth))+0

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors