Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi,
Good day.
I do have problem creating DAX to my report. See details below:
here's my generated report or the origin file:
and I want the file above turn into this:
Please disregard other column if you find it hard to create DAX. I only need to the Audited Amount and the Doc Code - relationship.
thanks in advance
Solved! Go to Solution.
Hi, @Anonymous
Please modify the calculated table as below.
Result table =
var tab =
FILTER(
SUMMARIZE(
'Table',
'Table'[Doc Code],
'Table'[Doc Code Sign],
'Table'[Orig Amount],
'Table'[Department]
),
'Table'[Doc Code Sign] = "Y"
)
var newtab =
ADDCOLUMNS(
tab,
"Row#",
RANKX(
tab,
[Doc Code],,ASC
)
)
var result =
ADDCOLUMNS(
newtab,
"Audited Amt",
IF(
COUNTROWS(
FILTER(
ALL('Table'),
'Table'[Doc Code]=EARLIER('Table'[Doc Code])
)
)=
COUNTROWS(
FILTER(
ALL('Table'),
'Table'[Doc Code]=EARLIER('Table'[Doc Code])&&
'Table'[Doc Code Sign] = "Y"
)
),
CALCULATE(
SUM('Table'[Audited Amt]),
FILTER(
ALL('Table'),
'Table'[Doc Code]=EARLIER('Table'[Doc Code])
)
),
CALCULATE(
SUM('Table'[Audited Amt]),
FILTER(
ALL('Table'),
'Table'[Doc Code]=EARLIER('Table'[Doc Code])&&
'Table'[Doc Code Sign]<>"Y"
)
)
)
)
return
result
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Anonymous
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may create a calculated table as below.
Result table =
var tab =
FILTER(
SUMMARIZE(
'Table',
'Table'[Doc Code],
'Table'[Doc Code Sign],
'Table'[Orig Amount],
'Table'[Department]
),
'Table'[Doc Code Sign] = "Y"
)
var newtab =
ADDCOLUMNS(
tab,
"Row#",
RANKX(
tab,
[Doc Code],,ASC
)
)
var result =
ADDCOLUMNS(
newtab,
"Audited Amt",
IF(
COUNTROWS(
FILTER(
ALL('Table'),
'Table'[Doc Code]=EARLIER('Table'[Doc Code])
)
)<=2,
CALCULATE(
SUM('Table'[Audited Amt]),
FILTER(
ALL('Table'),
'Table'[Doc Code]=EARLIER('Table'[Doc Code])
)
),
CALCULATE(
SUM('Table'[Audited Amt]),
FILTER(
ALL('Table'),
'Table'[Doc Code]=EARLIER('Table'[Doc Code])&&
'Table'[Doc Code Sign]<>"Y"
)
)
)
)
return
result
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Good day.
Thanks for this. However, what if this is my origin table (see below). I just changed a bit from the data. I used the same formula (DAX) but it didnt give the same result.
The outcome is the same:
TIA 🙂
Hi, @Anonymous
I modified the data as what you have done. It works properly. The pbix file is attached in the end.
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Apology but the outcome gave different result. See difference below:
My Expected Outcome: Row#1 (Column: Audited Amt) = 500
To reiterate, this is the base data, in highlighted color:
TIA 🙂
Hi, @Anonymous
Please modify the calculated table as below.
Result table =
var tab =
FILTER(
SUMMARIZE(
'Table',
'Table'[Doc Code],
'Table'[Doc Code Sign],
'Table'[Orig Amount],
'Table'[Department]
),
'Table'[Doc Code Sign] = "Y"
)
var newtab =
ADDCOLUMNS(
tab,
"Row#",
RANKX(
tab,
[Doc Code],,ASC
)
)
var result =
ADDCOLUMNS(
newtab,
"Audited Amt",
IF(
COUNTROWS(
FILTER(
ALL('Table'),
'Table'[Doc Code]=EARLIER('Table'[Doc Code])
)
)=
COUNTROWS(
FILTER(
ALL('Table'),
'Table'[Doc Code]=EARLIER('Table'[Doc Code])&&
'Table'[Doc Code Sign] = "Y"
)
),
CALCULATE(
SUM('Table'[Audited Amt]),
FILTER(
ALL('Table'),
'Table'[Doc Code]=EARLIER('Table'[Doc Code])
)
),
CALCULATE(
SUM('Table'[Audited Amt]),
FILTER(
ALL('Table'),
'Table'[Doc Code]=EARLIER('Table'[Doc Code])&&
'Table'[Doc Code Sign]<>"Y"
)
)
)
)
return
result
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.