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

How to create a table of distinct values and columns from an existing table and calculated columns?

I have a data table that is created from merging several queries together. I was to use this data table that is an aggregation of many queires to create a simpler table that will be needed for some final calculations.

 

The table created from queries

Model TypeModel IDWork Order CountStrategy Compliant
A1123Y
B1132N
C1145Y
A1154

Y

A1153

N

 

The table I want to create from the above

Distinct Model TypeDistinct Model IDSum Work Order CountCount  Model IDCount Model ID Strategy Compliant
A112311
A115721
B113210
C114511

 

Then I would like to add calculated columns like % compliant which would be the last column divided by the second to last column.

 

I believe to start this process I will need to use DAX formulas to reference the first table. Or is it possible to create this table in the query editor?

1 ACCEPTED SOLUTION
V-pazhen-msft
Community Support
Community Support

@Anonymous 

Summarize should work, but I think you need to change a bit in the formula above.

Table 2 = 
SUMMARIZE (
    'Table',
    'Table'[Model Type],
    'Table'[Model ID],
    "Sum Work Order Count", CALCULATE (
        SUM ( 'Table'[Work Order Count] ),
        ALLEXCEPT ( 'Table', 'Table'[Model ID] )
    ),
    "Count Model ID", COUNT ( 'Table'[Model ID] ),
    "Count Model ID Strategy Compliant", COUNTX (
        FILTER ( 'Table', 'Table'[Strategy Compliant] = "Y" ),
        'Table'[Model ID]
    )
)

 
Best,
Paul

View solution in original post

3 REPLIES 3
V-pazhen-msft
Community Support
Community Support

@Anonymous 

Summarize should work, but I think you need to change a bit in the formula above.

Table 2 = 
SUMMARIZE (
    'Table',
    'Table'[Model Type],
    'Table'[Model ID],
    "Sum Work Order Count", CALCULATE (
        SUM ( 'Table'[Work Order Count] ),
        ALLEXCEPT ( 'Table', 'Table'[Model ID] )
    ),
    "Count Model ID", COUNT ( 'Table'[Model ID] ),
    "Count Model ID Strategy Compliant", COUNTX (
        FILTER ( 'Table', 'Table'[Strategy Compliant] = "Y" ),
        'Table'[Model ID]
    )
)

 
Best,
Paul

amitchandak
Super User
Super User

Try summarize

summarize(table,table[Model Type],table[Model ID],"Sum Work Order Count",Table[Work Order Count],"Count  Model ID", count(Table[Model ID])
, "Strategy Compliant",countx(filter(table,table[Strategy Compliant]="Y"), Table[Model ID]))

 

https://docs.microsoft.com/en-us/dax/summarize-function-dax

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

Hi @Anonymous ,

 

i think you can use Power Query with Group-By

20200114_Strategy.png

 

20200114_Group_By.png

 

Regards,

Marcus

Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


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.