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
Anonymous
Not applicable

Simple DAX (why is this so hard to grasp)

Hi all,

 

I've done bits in batch scripting, VBScripting, VBA. I know Java, HTML, PHP and SQL. For some reason, I am really struggling to understand even the basic concepts of DAX.

 

I have sales data lets say item_name, sale_price, item_category. All i want to do is sum the total sale_price per item_category. Lets say i have 4 categories. So i want the output to be like this this (totals per category)

 

Category1 - 15000

Category2 - 21000

Category3 - 3000

Category4 - 6500

 

then from that I am going to convert the data into percentages. Ie:

 

Category1 - 32%

Category2 - 46%

Category3 - 6.5%

Category4 - 14%

 

this takes me literally 1 minute in excel. Yet i've spent 2 hours now trying to get it going in Power BI. The problem I keep having is it just outputs 1 number, the total of everything. I'd give you my attempts so far but i've literally tried writing this 10 different ways (and didn't save all the different ways). This is absolute last way i've tried

 

% Mix = SUM(Table1[unitprice_exclusive])/CALCULATE(SUM(Table1[unitprice_exclusive]), ALL(Table1[gl_description]))

and

% Mix = SUM(Table1[unitprice_exclusive])/CALCULATE(SUM(Table1[unitprice_exclusive]), ALL(Table1))

1 ACCEPTED SOLUTION

Glad to be of help to you. It takes only less than a minute.  One more snip to help you.

 

From Visualization pane>Choose Matrix and plot the columns as per the screenshot

 

Capture.JPG

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

6 REPLIES 6
smpa01
Super User
Super User

Is this what are you looking for @Anonymous

 

Capture.JPG

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

Yes that is exactly what im after

Glad to be of help to you. It takes only less than a minute.  One more snip to help you.

 

From Visualization pane>Choose Matrix and plot the columns as per the screenshot

 

Capture.JPG

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

okay so your solution is that i shouldn't use DAX for this?

You may probaly land in the same solution using a custom made complex DAX script (not sure though). But if the built-in operation can give you the same result why waste time?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

I didnt know it would be complex (and i already knew how to do what you suggested). There is a bunch of other stuff i've been asked to do with the data, I was also hoping to learn more from provided solutions

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.