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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
WTAS80486
Helper IV
Helper IV

How to Calculate cumulative count from one table based on months in another table

Measure is:

 

COUNT() = COUNTX(FILTER(Table 1, Table 1[PM/CM] = "Corrective"

&& Table 1[Month Number(Failed Date)] <> BLANK()

&& Table 1[Month Name(Failed Date)] =MAX('Table 2[Month Name])),  Table 1[PM/CM])

 

‘Table 1’  filtered by asset no:

 

It has dec, Jan and June entries for this asset

 

 

It also has this column Table1[PM/CM]

 

Table 2 looks like this and has nov-jul entries

 

 

Now cumulative count has to be calculated Nov to Jul

 

Ankita80486_2-1660050624678.png

 

 

Ankita80486_3-1660050624680.png

 

 

So for Jan count should be 3 and march also 3.

 

Can anyone help!

 

 

2 ACCEPTED SOLUTIONS
SpartaBI
Community Champion
Community Champion

@WTAS80486 make sure you have the proper dimensions between the different facts and don't created a relationship between the facts themselves.
And create these measures:

COUNT(failures_month) V2 = 
COUNTROWS(
    FILTER(
        Workorder_with_assetdowntime_MTBF, 
        Workorder_with_assetdowntime_MTBF[PM/CM] = "Corrective" 
            && Workorder_with_assetdowntime_MTBF[Month Number(Failed Date)] <> BLANK()
    )
)

COUNT(failures_month) V2 Cummulative = 
VAR _max_date = max('Date'[Date])
VAR _max_peossible_date = MAX(Workorder_with_assetdowntime_MTBF[Failed Date New])
RETURN
CALCULATE(
    [COUNT(failures_month) V2], 
    'Date'[Date] <= _max_date && 'Date'[Date] <= _max_peossible_date
)

View solution in original post

Change this part:

IF(
    _max_date <= _max_peossible_date,
 
To this
 
IF(
EOMONTH(  _max_date, -1) <= _max_peossible_date,

View solution in original post

5 REPLIES 5
WTAS80486
Helper IV
Helper IV

@SpartaBI Its working! Thanks so much!

SpartaBI
Community Champion
Community Champion

@WTAS80486 make sure you have the proper dimensions between the different facts and don't created a relationship between the facts themselves.
And create these measures:

COUNT(failures_month) V2 = 
COUNTROWS(
    FILTER(
        Workorder_with_assetdowntime_MTBF, 
        Workorder_with_assetdowntime_MTBF[PM/CM] = "Corrective" 
            && Workorder_with_assetdowntime_MTBF[Month Number(Failed Date)] <> BLANK()
    )
)

COUNT(failures_month) V2 Cummulative = 
VAR _max_date = max('Date'[Date])
VAR _max_peossible_date = MAX(Workorder_with_assetdowntime_MTBF[Failed Date New])
RETURN
CALCULATE(
    [COUNT(failures_month) V2], 
    'Date'[Date] <= _max_date && 'Date'[Date] <= _max_peossible_date
)

Thanks @SpartaBI for the solution. You are so helpful!

@SpartaBI 

 

This measure:

 

COUNT(failures_month) V2 Cummulative =
VAR _max_date = max('dimDate'[Date])
VAR _max_peossible_date = calculate(max(MAX(Workorder_with_assetdowntime_MTBF[Date(Failed)]),MAX('Runhours_Total Hours_By Month'[Date(Start)])), REMOVEFILTERS(dimDate),  Workorder_with_assetdowntime_MTBF[PM/CM] = "Corrective"
            ,Workorder_with_assetdowntime_MTBF[Month Name(Failed Date)] <> BLANK())
RETURN
IF(
    _max_date <= _max_peossible_date,
    CALCULATE(
        [COUNT(failures_month) V2],
    'dimDate'[Date] <= _max_date
    )+0
)
 
 
Is not populating cumulative count for last month, JULY in this case, This last month is Date(start) from runhours_totalhours table. 
 
Ankita80486_1-1660074110061.png

Date(failed) from workorder_with_asset downtime table

 

Ankita80486_2-1660074177708.png

 

 

 

Change this part:

IF(
    _max_date <= _max_peossible_date,
 
To this
 
IF(
EOMONTH(  _max_date, -1) <= _max_peossible_date,

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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.