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
Anonymous
Not applicable

show status from previous month

Dear All,

 

I would like to ask for your help on the below topic. 

 

What I am trying to see is how many people came back from maternity and under which status per month.

 

DateNameStatus
31/07/2020Goerge MichaelMaternity/Paternity
31/08/2020Goerge MichaelActive
31/07/2020ShakiraMaternity/Paternity
31/08/2020ShakiraUnpaid Leave

 

so at the end of the day i want to see that I have 1 active and 1 updaid leave. Think also that the list is big and there are people who are always active or contuining maternity.Capture.PNG

 

thank you,

 

Paris

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @ppatris ,

 

Here are the steps you can follow to achieve:

 

1.Create a calendar Table, Column, Measure.

 

Table:
Date = CALENDARAUTO()

Column:
Status End date =
var_nextsdate=CALCULATE(MAX('Table'[Date]),FILTER(ALL('Table'),'Table'[Name]=EARLIER('Table'[Name])&&'Table'[Date]>EARLIER('Table'[Date])&&'Table'[Status]<>EARLIER('Table'[Status])))
return _nextsdate

Measure:
Count =
var _count= CALCULATE (
    DISTINCTCOUNT( 'Table'[Name]) ,
    FILTER (
        'Table',
        (
           'Table'[Date] <= MIN( 'Date'[Date] )
                &&if(ISBLANK('Table'[Status End date]),CALCULATE(MAX('Date'[Date]),ALL('Date'[Date])),'Table'[Status End date]) > MAX ( 'Date'[Date]  )        
       )
    ),
    VALUES ('Table'[Name]))

return _count

 

 

2. Create a line chart.

v-yangliu-msft_0-1602207255929.png

 

3. Result.

v-yangliu-msft_1-1602207255944.png

 

 

You can downloaded PBIX file from here.

 

 

If I misunderstood your logic, you can express your logic more clearly.

Best Regards,

Liu Yang

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

View solution in original post

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @ppatris ,

 

Here is another method, the measure is modified:

 

1. Create a calendar Table, Measure.

Table:
Date = CALENDARAUTO()


Measure:
Count1 =
var _count= CALCULATE (
    DISTINCTCOUNT( 'Table'[Name]) ,
    FILTER (
        ALLSELECTED('Table'),         YEAR('Table'[Date])=YEAR(MAX('Table'[Date])&&MONTH('Table'[Date])=MONTH(MAX('Table'[Date]))
    )
    ))

return _count

 

 

If I misunderstood your logic, you can express your logic more clearly.

 

Best Regards,

Liu Yang

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

v-yangliu-msft
Community Support
Community Support

Hi  @ppatris ,

 

Here are the steps you can follow to achieve:

 

1.Create a calendar Table, Column, Measure.

 

Table:
Date = CALENDARAUTO()

Column:
Status End date =
var_nextsdate=CALCULATE(MAX('Table'[Date]),FILTER(ALL('Table'),'Table'[Name]=EARLIER('Table'[Name])&&'Table'[Date]>EARLIER('Table'[Date])&&'Table'[Status]<>EARLIER('Table'[Status])))
return _nextsdate

Measure:
Count =
var _count= CALCULATE (
    DISTINCTCOUNT( 'Table'[Name]) ,
    FILTER (
        'Table',
        (
           'Table'[Date] <= MIN( 'Date'[Date] )
                &&if(ISBLANK('Table'[Status End date]),CALCULATE(MAX('Date'[Date]),ALL('Date'[Date])),'Table'[Status End date]) > MAX ( 'Date'[Date]  )        
       )
    ),
    VALUES ('Table'[Name]))

return _count

 

 

2. Create a line chart.

v-yangliu-msft_0-1602207255929.png

 

3. Result.

v-yangliu-msft_1-1602207255944.png

 

 

You can downloaded PBIX file from here.

 

 

If I misunderstood your logic, you can express your logic more clearly.

Best Regards,

Liu Yang

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

Pragati11
Super User
Super User

Hi @Anonymous ,

 

As your data is not sufficient to create a sensible line chart, try as below:

  • Select a LIne chart visual and move your column fields as shown in the screenshot below:
  • Pragati11_0-1601887631652.png

     

See if this helps.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

amitchandak
Super User
Super User

@Anonymous , Try with time intelligence and date table

 

last MTD Sales = CALCULATE(MAx(Table[Status]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi


Appreciate your Kudos.

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.