Forum Discussion
Calculate with Filtering on AccountID (hardcoded) is working but not working on AccountID (dynamic)
- 2 years ago
Hey Anonymous
I have tried my own way by using a pretty simple approach i.e. using selectedvalue function and it's working perfect in the measure and made it dynamic -
I have applied the same concept in the sample POC file that I provided for you (attached) -
and it's also working fine in the sample file -But anyway, thanks for your help. I really appreciate it. You are a very talneted guy I must say.
Hats off 💥
.pbix file with my dynamic measure -
https://drive.google.com/file/d/1jRhL9q_ytVP4OxSyjntFliLqdm_IXynP/view?usp=sharing
Hi, Gazi_Sohan
here is my solution:
The condition you set in the measure's calculate function is incorrect, we also need to restrict the Category. To solve this wrong, use the following DAX expression:
Dynamic Accounts =
var selectedrecord = SELECTEDVALUE('COA Summary'[Account ID])
RETURN
SWITCH(
selectedrecord,
106,
CALCULATE(
SUM(Transactions[Amount]),
ALL('COA Details'),
'COA Details'[Category]="Revenues"&&
'COA Details'[Account ID] >= 'COA Details'[Operator Between Start]
&& 'COA Details'[Account ID] <= 'COA Details'[Operator Between End]
),
206,
CALCULATE(
SUM(Transactions[Amount]),
ALL('COA Details'),
'COA Details'[Category]="Expenses"&&
'COA Details'[Account ID] >= 'COA Details'[Operator Between Start]
&& 'COA Details'[Account ID] <= 'COA Details'[Operator Between End]
),
CALCULATE(
SUM(Transactions[Amount]),
'COA Details'[Account ID] >= 'COA Details'[Operator Between Start]
&& 'COA Details'[Account ID] <= 'COA Details'[Operator Between End]
)
)
A screenshot of the formula is shown below:
The results are as follows:
This way we can get the correct Total Expenses and Total Revenues by dynamic measure.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hey Anonymous
I have tried my own way by using a pretty simple approach i.e. using selectedvalue function and it's working perfect in the measure and made it dynamic -
I have applied the same concept in the sample POC file that I provided for you (attached) -
and it's also working fine in the sample file -
But anyway, thanks for your help. I really appreciate it. You are a very talneted guy I must say.
Hats off 💥
.pbix file with my dynamic measure -
https://drive.google.com/file/d/1jRhL9q_ytVP4OxSyjntFliLqdm_IXynP/view?usp=sharing