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
irnm8dn
Post Prodigy
Post Prodigy

DAX Statement Help - counts within column

I am currently using a DAX function to indicate whether particluar row (unit of inventory) is Sold or Available. This is column that is added to the dataset in PowerBI (for each row) using an "if" statement.

 

I want to further the use the information in this column by doing the following in a  a waffle chart (already downloaded).

 

1.  How many units are "Available"

2.  How many units are "Sold"

3.  How many total units of Inventory (Available + Sold)

 

I am trying to arrive at the following as well.

 

5.  % of units Available (Count of Available divided by Total Inventory)

6.  % of units Sold (Count of Sold divided by Total Inventory)

 

 

1 ACCEPTED SOLUTION
GilbertQ
Super User
Super User

Hi @irnm8dn,

 

If you have got a column which has the actual values 

 

EG: Column name: Status

  • Column Values: Available, Sold

Then what you can do is to create the following Measures

 

Total Inventory = CountRows('TableName')

Available = CALCULATE([Total Inventory],'TableName'[Status] = "Available")

Sold = CALCULATE([Total Inventory],'TableName'[Status] = "Sold")

% Units Available = DIVIDE([Available],[Total Inventory])

% Units Sold = DIVIDE([Sold],[Total Inventory])




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

View solution in original post

2 REPLIES 2
GilbertQ
Super User
Super User

Hi @irnm8dn,

 

If you have got a column which has the actual values 

 

EG: Column name: Status

  • Column Values: Available, Sold

Then what you can do is to create the following Measures

 

Total Inventory = CountRows('TableName')

Available = CALCULATE([Total Inventory],'TableName'[Status] = "Available")

Sold = CALCULATE([Total Inventory],'TableName'[Status] = "Sold")

% Units Available = DIVIDE([Available],[Total Inventory])

% Units Sold = DIVIDE([Sold],[Total Inventory])




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

v-huizhn-msft
Employee
Employee

Hi @irnm8dn,

 

Would your please post same sample data, so we can analysis them directly? If your resource data is confidential, please create same sample data those structure likes your real data.

Best Regards,
Angelia

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.