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
johnsmith92
Regular Visitor

Divide the sum of a column member by the total of all columns

Hi all,

 

I am new to PowerBI (coming from Tableau) and I am struggling with creating a DAX measure.

 

So, first off, my data comes from a tabluar cube and a huuuuuge model and unforunately I can't share it, but I'll do my best to describe. My Values come from a huge table with records and are already summed in the model before loading to PowerBI. My Months come from the standard Date table in the model.

 

Here's what I'm trying to replicate in PowerBI (the last row):

screen1.png

 

Basically, this calculates the total share of each month for the last 4 years.

 

My target visual in PowerBI is this:

target1.PNG

 

I have tried a lot of things, but the only thing that worked is that I managed to replicate the Excel table (with % share instead of values) and it was dependent on the years included in the matrix (which I don't need). What I'm looking for is the last row with the blue text.

 

I tried to recreate the data in a pbix file: PBIX file 

 

Can you guys help me with this one?

1 ACCEPTED SOLUTION

Hi@johnsmith92,

 

please try measure like this :

Measure = 
var a=
CALCULATE(
    SUM('Values'[Values]),
    FILTER(
        'Values',
        MONTH('Values'[Date])=MONTH(MAX('Values'[Date]))
    ))
var b=
CALCULATE(
SUM('Values'[Values]),ALL('Values'))
return
IF(
    HASONEVALUE('Date'[MonthName]),
    a/b,
    1
)

 

then you will get :

555.png

 

Here is the demo ,please try it : https://qiuyunus-my.sharepoint.com/:u:/g/personal/admin_qiuyunus_onmicrosoft_com/EQDTU6PV8wRKvuQOxRT... 

 

 

Hope it helps.

 

Best Regards,
Caitlyn Yan

 

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

8 REPLIES 8
johnsmith92
Regular Visitor

I can get the value only for one month, as seen here:

 

Spoiler
test14.png

Understandibly it doesn't work:

 

 fadf.PNG 

Not sure if that's possible, but I want the above "Sum Months" calculation to replicate itself, depending which row is on the first column and replace the month part.

amitchandak
Super User
Super User

@johnsmith92 , you file is not opening, can you share the formula

Could it be because I'm on January 2021 version?

@johnsmith92 , I am not Feb 2021, so it should open. Please share formula/measures, I will try to check

Have you been able to open the file, sir?

Hi@johnsmith92,

 

please try measure like this :

Measure = 
var a=
CALCULATE(
    SUM('Values'[Values]),
    FILTER(
        'Values',
        MONTH('Values'[Date])=MONTH(MAX('Values'[Date]))
    ))
var b=
CALCULATE(
SUM('Values'[Values]),ALL('Values'))
return
IF(
    HASONEVALUE('Date'[MonthName]),
    a/b,
    1
)

 

then you will get :

555.png

 

Here is the demo ,please try it : https://qiuyunus-my.sharepoint.com/:u:/g/personal/admin_qiuyunus_onmicrosoft_com/EQDTU6PV8wRKvuQOxRT... 

 

 

Hope it helps.

 

Best Regards,
Caitlyn Yan

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

That works perfectly! Thank you so much!

Hi @amitchandak . There's no formulas for the data, I have just put it in PowerBI manually. Can you try this again? New PBIX file 

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.