Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

Value on matrix drill-down, shown before selecting the drill down option.

Hi everybody, Im creating a matrix in PowerBi that displays various data. One of those is the "aging" of a certain item, so it will be displayed on the last day of the month.
The issue I'm facing is that the value will not be shown unless I drill down to "DAY"via Date Hierarchy (Month, Day), but I need it to be displayed also when showing the month. 
Can anyone help me solve this?
-----------------------------------------------------

AGING average eomonth =
IF(
    SELECTEDVALUE('Foglio1'[eomonth]) = 1,
DIVIDE(
    SUM(Foglio1[Aging]),
    SUM(Foglio1[Giacenza]),
    BLANK()),
    BLANK())
----------------------------------------------------
eomonth =
VAR currentMonth =
    MONTH('Foglio1'[Data])

VAR latestDateofMonth =
    CALCULATE(
        MAX('Foglio1'[Data]),
        FILTER(ALL('Foglio1'), MONTH('Foglio1'[Data])=currentMonth && 'Foglio1'[Giacenza] <> BLANK())
    )
RETURN
    IF('Foglio1'[Data] =latestDateofMonth, 1, 0)

----------------------------------------------------

2 Replies

  • Anonymous 

    It seems like you're trying to calculate the aging of certain items on the last day of each month and display it in a matrix in Power BI. The issue you're facing is that the aging value is not shown unless you drill down to the "DAY" level via Date Hierarchy (Month, Day), but you need it to be displayed even when showing the month.

    To address this issue, you can modify your DAX measures to ensure that the aging value is calculated correctly at both the month and day levels. Here's how you can modify your measures:

    1. **AGING average eomonth**:
    ```DAX
    AGING average eomonth =
    VAR CurrentMonth = MONTH('Foglio1'[Data])
    VAR LatestDateOfMonth =
    CALCULATE(
    MAX('Foglio1'[Data]),
    FILTER(ALL('Foglio1'), MONTH('Foglio1'[Data]) = CurrentMonth && 'Foglio1'[Giacenza] <> BLANK())
    )
    RETURN
    IF('Foglio1'[eomonth] = 1,
    DIVIDE(
    CALCULATE(
    SUM('Foglio1'[Aging]),
    'Foglio1'[Data] = LatestDateOfMonth
    ),
    CALCULATE(
    SUM('Foglio1'[Giacenza]),
    'Foglio1'[Data] = LatestDateOfMonth
    ),
    BLANK()
    ),
    BLANK()
    )
    ```

    2. **eomonth**:
    ```DAX
    eomonth =
    VAR CurrentMonth = MONTH('Foglio1'[Data])
    VAR LatestDateOfMonth =
    CALCULATE(
    MAX('Foglio1'[Data]),
    FILTER(ALL('Foglio1'), MONTH('Foglio1'[Data]) = CurrentMonth && 'Foglio1'[Giacenza] <> BLANK())
    )
    RETURN
    IF('Foglio1'[Data] = LatestDateOfMonth, 1, 0)
    ```

    Make sure to replace `'Foglio1'` with the actual name of your table.

    With these modifications, your measures should correctly calculate the aging values for the last day of each month and display them in the matrix even when not drilling down to the "DAY" level.

    Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thank you for your solution  johnbasha33 
    Hi,  Anonymous 

    Have you solved your problem? If so, can you share your solution here and mark the correct answer as a standard answer to help other members find it faster? Thank you very much for your kind cooperation!

     

    Best Regards

    Jianpeng Li