cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
usman96
Helper II
Helper II

Remaining Days of Month Calculation

tmp.PNG

I have this column which have dates  , these dates show the day on which employees are "present"

How to calculate absent days (other days which are not in this column) ? in powerbi 

 

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

Hi @usman96,

 

You can use below calculate column to achieve your requirement:

present =
COUNTROWS (
    FILTER (
        ALL ( list ),
        YEAR ( [Date] ) = YEAR ( EARLIER ( list[Date] ) )
            && MONTH ( [Date] ) = MONTH ( EARLIER ( list[Date] ) )
    )
)

absent = 
DAY ( DATE ( YEAR ( [Date] ), MONTH ( [Date] ) + 1, 1 ) - 1 )
    - [present]

Result:

8.PNG

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

5 REPLIES 5
v-shex-msft
Community Support
Community Support

Hi @usman96,

 

You can use below calculate column to achieve your requirement:

present =
COUNTROWS (
    FILTER (
        ALL ( list ),
        YEAR ( [Date] ) = YEAR ( EARLIER ( list[Date] ) )
            && MONTH ( [Date] ) = MONTH ( EARLIER ( list[Date] ) )
    )
)

absent = 
DAY ( DATE ( YEAR ( [Date] ), MONTH ( [Date] ) + 1, 1 ) - 1 )
    - [present]

Result:

8.PNG

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Phil_Seamark
Microsoft
Microsoft

HI @usman96

 

You could join to a Date table and add two columns.  The first column showing a 1 on dates that match your list.  The second column shows a 1 on days where there is no match.

 

Does that sound like it might work for you?

 


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

Proud to be a Datanaut!

it would be better if could show them in bar dual bar chart 

 

The first bar show the present days  in number like ( 7 present days)

and the 2nd chart show the absent days  in numbers like ( 2 absent days ) 

Can you show me how to achieve this ? 

HI @usman96

 

Can you please mock something up (using your sample data) as I'm still not 100% clear.

 

I'm sure it's possible to come up with a formula, I just don't understand what you are trying to do (Sorry)

 


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

Proud to be a Datanaut!

"You could join to a Date table and add two columns.  The first column showing a 1 on dates that match your list.  The second column shows a 1 on days where there is no match."

Can you implement this and give me some sample of what you said ?

Helpful resources

Announcements
August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 24 without aka link and time 768x460.jpg

Ted's Dev Camp - July 28, 2022

Watch Session 24 of Ted's Dev Camp along with past sessions!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors