The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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
)
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]
)
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.
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'.
Link to sample file
https://www.dropbox.com/s/3cw1brpqsx2rbm1/test%20active%20charges.pbix?dl=0
Solved! Go to Solution.
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"
)
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"
)
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" )