最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

dax - Measure in PowerBI not displaying title for pie chart properly when there is no data - Stack Overflow

programmeradmin1浏览0评论

I have bookmark page, “Sourcing area pie chart”, that has pie charts for all sourcing areas in our system. All the pie charts are filtered per sourcing area under “Filters” for the visuals. I have a measure that is dynamically adjusted.

For example if we have a pie chart filtered for sourcing area Y,

The user selects growing season X and there is data for Y in growing season X, then the title should show,

“Input cost % for Y in X” – case A

and in the case that there is no data for Y in growing season X it should show,

“No data available for Y” – case B

However, currently the measure only works with case A, and case B not. The issue seems to stem from if there is data for a sourcing area for a specific growing season. If there is, the measure works as intended, if there isn’t it does not work.

I am not sure what the issue is and how to fix it. I have made sure the slicer for sourcing is not affecting the pie chart, but the issue persists.

Measure used:

_SourcingareaPietitle =

IF(
    ISBLANK(MAX('CAD$,T,Ha'[Growing Season])) || 
    ISBLANK(SELECTEDVALUE('CAD$,T,Ha'[Delivery period])) || 
    ISBLANK(SELECTEDVALUE('CAD$,T,Ha'[DataType])), 
    "No data available for " & 
    SELECTEDVALUE('CAD$,T,Ha'[Sourcing Area], MAX('CAD$,T,Ha'[Sourcing Area])), 
    "Input cost % for " & 
    SELECTEDVALUE('CAD$,T,Ha'[Sourcing Area], MAX('CAD$,T,Ha'[Sourcing Area])) & 
    " in " & 
    MAX('CAD$,T,Ha'[Growing Season])
)

I have bookmark page, “Sourcing area pie chart”, that has pie charts for all sourcing areas in our system. All the pie charts are filtered per sourcing area under “Filters” for the visuals. I have a measure that is dynamically adjusted.

For example if we have a pie chart filtered for sourcing area Y,

The user selects growing season X and there is data for Y in growing season X, then the title should show,

“Input cost % for Y in X” – case A

and in the case that there is no data for Y in growing season X it should show,

“No data available for Y” – case B

However, currently the measure only works with case A, and case B not. The issue seems to stem from if there is data for a sourcing area for a specific growing season. If there is, the measure works as intended, if there isn’t it does not work.

I am not sure what the issue is and how to fix it. I have made sure the slicer for sourcing is not affecting the pie chart, but the issue persists.

Measure used:

_SourcingareaPietitle =

IF(
    ISBLANK(MAX('CAD$,T,Ha'[Growing Season])) || 
    ISBLANK(SELECTEDVALUE('CAD$,T,Ha'[Delivery period])) || 
    ISBLANK(SELECTEDVALUE('CAD$,T,Ha'[DataType])), 
    "No data available for " & 
    SELECTEDVALUE('CAD$,T,Ha'[Sourcing Area], MAX('CAD$,T,Ha'[Sourcing Area])), 
    "Input cost % for " & 
    SELECTEDVALUE('CAD$,T,Ha'[Sourcing Area], MAX('CAD$,T,Ha'[Sourcing Area])) & 
    " in " & 
    MAX('CAD$,T,Ha'[Growing Season])
)

Share Improve this question edited Nov 20, 2024 at 19:32 Amira Bedhiafi 1 asked Nov 20, 2024 at 17:49 Sadredin MahmoudiSadredin Mahmoudi 12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I think you have a problem with the filtering context and how ISBLANK interacts with your model specifically, if no rows exist in the table for the given filtering combination, the measure may not evaluate as expected so you may try the below :

_SourcingareaPietitle = 
IF(
    ISBLANK(
        CALCULATE(
            MAX('CAD$,T,Ha'[Growing Season]),
            REMOVEFILTERS('CAD$,T,Ha')
        )
    ),
    "No data available for " & 
    SELECTEDVALUE('CAD$,T,Ha'[Sourcing Area], MAX('CAD$,T,Ha'[Sourcing Area])),
    "Input cost % for " & 
    SELECTEDVALUE('CAD$,T,Ha'[Sourcing Area], MAX('CAD$,T,Ha'[Sourcing Area])) & 
    " in " & 
    MAX('CAD$,T,Ha'[Growing Season])
)
发布评论

评论列表(0)

  1. 暂无评论