Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
harrypotter
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) :

dax.jpg

Please help me achieve the above functionality in Power BI. Thanks in advanced.

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

@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]))

 

1.png

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.

View solution in original post

2 REPLIES 2
v-yuezhe-msft
Employee
Employee

@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]))

 

1.png

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.

Thanks Lydia for the solution! 🙂 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.