cancel
Showing results for
Did you mean:
Highlighted
New Member

## Achieve the dynamic field calculation in Power BI using DAX

I have a MDX query that needs to be converted in DAX in Power BI. MDX:

```CASE WHEN ISEMPTY( [Measures].[Total] )
THEN NULL ELSE IIF(ISEMPTY( Axis(1).Item(0).Item(0).Dimension.Levels(0).item(0)),1,[Measures].[Total] / (Axis(1).Item(0).Item (0).Dimension.Levels(0).item(0), [Measures].[Total] )) ENDTotal / (The Total of the entire columnar data)```

I assume that the above query is: Total is Aggregated sum of the data as per month or any dimension and % Total is:

`Total / (The Total of the entire columnar data)`

Please see the below screenshot (Sample data) :

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft

## Re: Achieve the dynamic field calculation in Power BI using DAX

@harrypotter,

Please create a new column using the DAX below and check if you get expected result.

`Total % = if(ISBLANK(SampleData[Total]),BLANK(),SampleData[Total]/sum(SampleData[Total]))`

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 REPLIES 2
Highlighted
Microsoft

## Re: Achieve the dynamic field calculation in Power BI using DAX

@harrypotter,

Please create a new column using the DAX below and check if you get expected result.

`Total % = if(ISBLANK(SampleData[Total]),BLANK(),SampleData[Total]/sum(SampleData[Total]))`

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
New Member

## Re: Achieve the dynamic field calculation in Power BI using DAX

Thanks Lydia for the solution! 🙂

Announcements

#### August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

#### Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

#### Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

#### Community Summit Australia – Join Online!

Be a part of the leading Microsoft Business Applications digital event, curated for the APAC community.

Top Solution Authors
Top Kudoed Authors