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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Count running accruals

Hi all,

 

I am want to make a measure that counts the current running accruals of a company. Here's how the raw data would look like on the left, and I plan to arrange the data like this on the right:

 

1.png                           2.png  

 

From the arranged data, what should happen is that the measure will count the instances where an accrual is incurred from the most recent AfP period which is "10", and the measure will stop counting if the there is a 0 or blank encountered. If the value returned from the most recent period is zero or blank, the measure will not count or should return a value of 0. The expected result of the measure should be like this:

 

3.png

 

Any kind of help is appreciated. Thank you!

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Is that the excepted result you need?

 

Measure 3 =
SUMX (
    FILTER (
        ALL ( Table2[Supplier] ),
        Table2[Supplier] <= MAX ( Table2[Supplier] )
    ),
    [Measure 2]
)

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

8 REPLIES 8
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

To create a measure as below.

 

Measure = 
VAR maxmonth =
    MAXX ( ALL ( Table1 ), Table1[Month] )
VAR maxmonth0 =
    CALCULATE (
        MAX ( Table1[Month] ),
        FILTER ( ALL ( Table1 ), Table1[Cost] = 0 ),
        VALUES ( Table1[Supplier] )
    )
VAR a =
    CALCULATE ( SUM ( Table1[Cost] ), FILTER ( Table1, Table1[Month] = maxmonth ) )
RETURN
    IF (
        a = 0,
        0,
        CALCULATE (
            COUNT ( Table1[Cost] ),
            FILTER ( Table1, Table1[Month] > maxmonth0 && Table1[Month] <= maxmonth )
        )
    )

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

hi @v-frfei-msft ,

 

What if I have multiple entries of cost for one period/month, what would I add into the measure? My actual raw data is like this: 

acc2.png

 

The cost type is categorized into two types: Accrual and Actual. I've added a filter to consider only the Accrual cost and replaced the columns appropriate to my data, and when I inserted the measure, the result looked like this:

 

acc.png

 

Thanks for the help

Hi @Anonymous ,

 

Could you please create a sample pbix to me? Please upload your files to One Drive and share the link here.

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

hi @v-frfei-msft

 

I can only send dummy/sample data, found in "Table 2". You can find the PBIX file here.

 

I added more than one data entry per period and also added cost type "Actual" to resemble my original raw data.

 

Thank you.

Hi @Anonymous ,

 

LRA = 
VAR k =
    FILTER ( Table2, Table2[type] = "accrual" )
VAR maxmonth =
    MAXX ( ALL ( Table2 ), Table2[Month] )
VAR maxmonth0 =
    CALCULATE (
        MAX ( Table2[Month] ),
        FILTER ( ALL ( Table2 ), Table2[Cost] = 0 ),
        VALUES ( Table2[Supplier] ),
        KEEPFILTERS ( k )
    )
VAR a =
    CALCULATE (
        SUM ( Table2[Cost] ),
        FILTER ( Table2, Table2[Month] = maxmonth ),
        KEEPFILTERS ( k )
    )
RETURN
    IF (
        a = 0,
        0,
        CALCULATE (
            DISTINCTCOUNT ( Table2[Month] ),
            FILTER ( Table2, Table2[Month] > maxmonth0 && Table2[Month] <= maxmonth ),
            KEEPFILTERS ( k )
        )
    )

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

hi @v-frfei-msft,

 

The result is almost realized. Apologies, I forgot to mention that the accruals for each company, per period should be displayed as a running total. I think I have to edit this part of the code?

VAR maxmonth0 =
    CALCULATE (
        MAX ( 'Central (FLO)'[AfP] ),
        FILTER ( ALL ( 'Central (FLO)' ), 'Central (FLO)'[Company code amount] = 0 ),
        VALUES ( 'Central (FLO)'[Company Name] ),
        KEEPFILTERS ( k )

Thanks for your continuous help.

 

Hi @Anonymous ,

 

Is that the excepted result you need?

 

Measure 3 =
SUMX (
    FILTER (
        ALL ( Table2[Supplier] ),
        Table2[Supplier] <= MAX ( Table2[Supplier] )
    ),
    [Measure 2]
)

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Hi, I'll check this out tomorrow. Thanks for the help! 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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