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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Calculate stock Number of current contracts per month with a visual table.

I would like to know how to calculate the number of current contracts of a customer with a visual table. I have made a copy of the table on the image below. This table is a filtered table. But with this copy, the dax formula does just fine. Only I don't know how to get this table in the formula.The calculation to count the contracts I have:


Number of current contracts per month =

VAR MinDatum2 = MAX(Dimdate_end[Date])

VAR MinDatum3 =MIN(Dimdate_end[Date])

RETURN

CALCULATE(

    COUNTROWS('Tabel (2)'),
    Dimdate_end[Date] >= MinDatum3 ,

    Dimdate[Date] <= MinDatum2

    )

2.png

I would like to use the table on the picture for my calculation. I probably have to build a visual table for this because the table on the picture is filtered. This table normally consists of 400 records. Because I use an earlier function to calculate the sum of hours of a current contract in the data. An index is placed on it and at the lowest in index is the sum of the number of hours of the contract. I use that to determine the contract. 

To determine this I use the following dax formula:

 

Contract >4 hours = If(Data[Index traject] = 1 &&
Data[Traject contract hours] >= 4,1,0)

But how can I Calculate stock Number of current contracts per month with a visual table?

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

>>But how can I Calculate stock Number of current contracts per month 

please try this measure,

measure =
CALCULATE (
    COUNTROWS ( Data ),
    FILTER (
        Data,
        [Contract >4 hours] = 1
            && YEAR ( Data[date] ) = YEAR ( MIN ( Dimdate[Date] ) )
            && MONTH ( Data[date] ) = MONTH ( MIN ( Dimdate[Date] ) )
    )
)

 

 

Best Regards,

Community Support Team _Tang

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

View solution in original post

3 REPLIES 3
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

>>But how can I Calculate stock Number of current contracts per month 

please try this measure,

measure =
CALCULATE (
    COUNTROWS ( Data ),
    FILTER (
        Data,
        [Contract >4 hours] = 1
            && YEAR ( Data[date] ) = YEAR ( MIN ( Dimdate[Date] ) )
            && MONTH ( Data[date] ) = MONTH ( MIN ( Dimdate[Date] ) )
    )
)

 

 

Best Regards,

Community Support Team _Tang

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

daXtreme
Solution Sage
Solution Sage

Hi there.

 

To me, it's not really clear what it is you want. Can you please simplify your question? Thanks. And please always remember that a picture is worth a thousand words 🙂

amitchandak
Super User
Super User

@Anonymous , refer if one the approach can help

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970

 

https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-or-end-date/ba-p/1503785

 

 


Between Dates - Dates between
Tables way
https://amitchandak.medium.com/dax-get-all-dates-between-the-start-and-end-date-8f3dac4ff90b
https://amitchandak.medium.com/power-query-get-all-dates-between-the-start-and-end-date-9ad6a84cf5f2

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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