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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
GunnerJ
Post Patron
Post Patron

calculate function is changing measure action

I'm needing to flag pending accounts when the value for an account's 'total as of date' is less than 1 and where the 'Action Flag' is "PENDING". 'Total as of date' returns the 'RUNNING_TOTAL' value of the max visible date thats less than the date filter. Both examples use the same date in the filter and the 'Pending Accounts' flag should not be marked since the 'total as of date' value is 2 in both examples. 

 

total as of date = 
var last_date = CALCULATE(
                    LASTNONBLANK('TEST CHARGES'[CHG_DATE], ""), 
                    'TEST CHARGES'[CHG_DATE] <= max('Test Charges Date Table'[Date])
                    )

return CALCULATE(
            min('TEST CHARGES'[RUNNING_TOTAL]),
             'TEST CHARGES'[CHG_DATE] = last_date
             )

GunnerJ_2-1661086699503.png

 

The code below is missing the piece that would add the "pending criteria.

Pending_Accounts = 

         Countx(
            Filter(
                Values('TEST CHARGES'[BI_ACCT]),
                 [total as of date] < 1 
            ) , [BI_ACCT] 
        )

 

GunnerJ_0-1661086277234.png

When I add in calculate with additional criteria for PENDING the measure acts very differently. 

Pending_Accounts = 
        CALCULATE(
            Countx(
                Filter(
                 Values('TEST CHARGES'[BI_ACCT]),
                    [total as of date] < 1 
                ) , [BI_ACCT] 
            ), 'TEST CHARGES'[ACTION_FLAG] = "PENDING"
        )

 The row level flags work to only flag rows where 'total as of date' is less than 1 and action flag is "PENDING" but it ignores the date aspect. 

GunnerJ_4-1661087965956.png

 

Adding the calculate filter seems to have the measure ignore the account level 'total as of date value. How can I add the "pending" criteria but also retain the 'total as of date' filter for the account? 

 

Just to show the total as of date value change if I move the date filter to Feb 7th 2020 the max date shown is the PENDING date on the 6th of FEB. The 'Total as of date' value then updates to 0. This is how the account should look when flagging 'Pending_Accounts'.

GunnerJ_3-1661087653778.png

 

Link to sample file 

https://www.dropbox.com/s/3cw1brpqsx2rbm1/test%20active%20charges.pbix?dl=0

 

1 ACCEPTED SOLUTION
GunnerJ
Post Patron
Post Patron

This code worked. I just had to switch the action flag piece. Making it equal to a value made the measure key in on specific rows. Saying NOT "STOP" let it look at the account as a whole.

 

Pending_Accounts = 
        CALCULATE(
            Countx(
                Filter(
                 Values('TEST CHARGES'[BI_ACCT]),
                    [total as of date] < 1 
                ) , [BI_ACCT] 
            ), 'TEST CHARGES'[ACTION_FLAG] <> "STOP"
        )

 

View solution in original post

2 REPLIES 2
GunnerJ
Post Patron
Post Patron

This code worked. I just had to switch the action flag piece. Making it equal to a value made the measure key in on specific rows. Saying NOT "STOP" let it look at the account as a whole.

 

Pending_Accounts = 
        CALCULATE(
            Countx(
                Filter(
                 Values('TEST CHARGES'[BI_ACCT]),
                    [total as of date] < 1 
                ) , [BI_ACCT] 
            ), 'TEST CHARGES'[ACTION_FLAG] <> "STOP"
        )

 

AlexisOlson
Super User
Super User

Without the "PENDING" filter, the measure [total as of date] returns 2. With that filter, the [total as of date] measure inside of the [Pending_Accounts] measure returns 0 since the last "PENDING" date had RUNNING_TOTAL = 0.

 

Try writing this measure to understand what's happening to [total as of date] inside of [Pending_Accounts] when you add the filter:

CALCULATE ( [total as of date], 'TEST CHARGES'[ACTION_FLAG] = "PENDING" )

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors