Forum Discussion
Top N based on specific column in MATRIX table
- Anonymous1 year ago
Hi mbudiman ,
Please try code as below.
New Net Revenue = IF ( HASONEVALUE ( 'Table'[FY_FISCAL_QTR] ), [Net Revenue], CALCULATE ( [Net Revenue], FY_FISCAL_QTR,FY_FISCAL_QTR[QTR_SEQ_NO] = 0 ) )Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi mbudiman ,
According to your statement, I think you want to sort the category by the last FY_FISCAL_QTR.
As far as I know, when you sort the matrix by data in value field, Power BI will sort it by subtotal.
So I suggest you to try code as below to diy the subtotal for [Net Revenue].
New Net Revenue =
IF (
HASONEVALUE ( 'Table'[FY_FISCAL_QTR] ),
[Net Revenue],
CALCULATE (
[Net Revenue],
'Table'[FY_FISCAL_QTR] = MAX ( DimDate[FY_FISCAL_QTR] )
)
)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
hi Rico,
Thanks for providing solution. It almost achieve the desired result. However, my custom Financial Calendar table contains future fiscal Quarter too, so using MAX function to retrieve current Fiscal Qtr does not work.
I need to retrieve current FIscal Qtr using condition Qtr_Seq_No = 0. Pls advise DAX statement to achieve this.
The following is the contain of FY_FISCAL_QTR table. Qtr_Seq_No = 0 means current Fiscal Qtr, Qtr_Seq_No = -1 means last Fiscal Qtr, Qtr_Seq_No = 1 means next future Fiscal Qtr.
The colum Qtr Order is used for sorting FY_FISCAL_QTR in Matrix table.
| FY_FISCAL_QTR | QTR_SEQ_NO | QTR ORDER |
| FY24Q1 | -5 | 8 |
| FY24Q2 | -4 | 7 |
| FY24Q3 | -3 | 6 |
| FY24Q4 | -2 | 5 |
| FY25Q1 | -1 | 4 |
| FY25Q2 | 0 | 3 |
| FY25Q3 | -1 | 2 |
| FY25Q4 | -2 | 1 |
Thank you in advance for your advise.
- Anonymous1 year agoNot applicable
Hi mbudiman ,
Please try code as below.
New Net Revenue = IF ( HASONEVALUE ( 'Table'[FY_FISCAL_QTR] ), [Net Revenue], CALCULATE ( [Net Revenue], FY_FISCAL_QTR,FY_FISCAL_QTR[QTR_SEQ_NO] = 0 ) )Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- mbudiman1 year agoHelper III
hi Rico,
The solution you provided above works perfectly !
Thank you so much 🙂