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
efowler
Helper II
Helper II

Correct DAX and Measure for % completed by State?

Hi,

 

I do not have my measure or DAX (or both) setup correct.  I searched and could not find any solutions.   Can you review and provide guidance on this? 

 

Data Info.   

Table 1 = Total Population of products that need to be "completed".  Each has a unique ESN and has assign state

Table 2 = Products that have been "completed".   Shown by ESN and date "completed.

 

When I tried the DAX and measure to show Percentage completed by State it is not working.  It is dividing the total count of completed divided by Total Quantity by State.   My Completed table does not have state data, it is related by ESN to total population table which has state.

 

The correct calculation should be Total number of completed in the specific State Divided by Total number of Population in that specific state.   Example = If California only has Qty 10 from the Total population.   And 2 products have been completed (Table 2) from Calfornia, then the percentage Completd for California = 20%.  

 

Right now it is calculating total completed divided by total in the state.  

 

DAX SYNTAX.jpg

percent complete not correct.jpgrelated tables.jpg

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Before anything else, try making the directon between your two tables completed and population Both instead of one direction.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
edhans
Super User
Super User

Can you provide some data, and what your measures are? For example one of your variables uses [count per state] but i don't know what that measure is, and I suspect that is part of the problem.

 

And you said Table1 and Table2  had some data, but your model doesn't show a Table1 or Table2.

 

If you could share your PBIX via OneDrive or DropBox that would be immensly helpful. Otherwise we will need to spend time typing in data just to get to where you are.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Hi, thank you for looking at the post..  The link below will allow you to download the data file and the .pbix file.

 

I mention Table 1 and Table 2 but they are named differently in the model (sorry).

 

Completed1 = Data showing what has been Completed (related by ESN)

Population = Data showing total population (related by ESN) 

 

https://app.box.com/s/w5x5utwdscw4efm6uxfkc5ewn2b0c3ut

 

Took a crack at this. No idea if the numbers are correct. PBIX is attached. Basically, changed the relationship as suggested earlier. Messed with the % Complete calc.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

Before anything else, try making the directon between your two tables completed and population Both instead of one direction.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Got it thank you!   Change the relationship cross filter to BOTH and rewrote the measure and it worked perfect..    Thank you!

 

Now I need to do some research on what exactly that does so I can understand it for the future..  

 

resolved.jpg

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.