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

Show quarter in column

I want to show value of every qtr in column for every name. instead of matrix it should be in table. and name should appear in every quarter. 

 

PS: i can't change my table into pivot table. 

Ex: 

INPUT TABLE
IDnameQTRAmt
123aQ150
123aQ210
456cQ350
456cQ450
456cQ150
456cQ250
1234345fQ350
1234345fQ450
1234345fQ150
1234345fQ250

 

OUTPUT TABLE   
IDNameQ1Q2Q3Q4Total
456c50505050200
1234345f50505050200
1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

You can create a calculated table like this:

Table = 
VAR tab =
    SUMMARIZE (
        'Input Table',
        'Input Table'[ID],
        'Input Table'[Name],
        "Q1", CALCULATE ( SUM ( 'Input Table'[Amt] ), 'Input Table'[QTR] = "Q1" ),
        "Q2", CALCULATE ( SUM ( 'Input Table'[Amt] ), 'Input Table'[QTR] = "Q2" ),
        "Q3", CALCULATE ( SUM ( 'Input Table'[Amt] ), 'Input Table'[QTR] = "Q3" ),
        "Q4", CALCULATE ( SUM ( 'Input Table'[Amt] ), 'Input Table'[QTR] = "Q4" )
    )
VAR newtab =
    SUMMARIZE (
        tab,
        'Input Table'[ID],
        'Input Table'[Name],
        [Q1],
        [Q2],
        [Q3],
        [Q4],
        "Total",
        VAR _rows = { [Q1], [Q2], [Q3], [Q4] }
        VAR _sum =
            SUMX ( FILTER ( _rows, [Value] <> BLANK () ), [Value] )
        RETURN
            _sum
    )
RETURN
    newtab

The table will like this:

table.png

You can put these fields in the table visual:

table re.png

 

Attached my sample file that hopes to help you, please check and try it: Show quarter in column.pbix

 

Best Regards,
Yingjie Li

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

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Just in case you wish to do this in the Query Editor, this M code does the job

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"name", type text}, {"QTR", type text}, {"Amt", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[QTR]), "QTR", "Amt"),
    #"Replaced Value" = Table.ReplaceValue(#"Pivoted Column",null,0,Replacer.ReplaceValue,{"Q1", "Q2", "Q3", "Q4"}),
    #"Added Custom" = Table.AddColumn(#"Replaced Value", "Total", each [Q1]+[Q2]+[Q3]+[Q4])
in
    #"Added Custom"

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

You can create a calculated table like this:

Table = 
VAR tab =
    SUMMARIZE (
        'Input Table',
        'Input Table'[ID],
        'Input Table'[Name],
        "Q1", CALCULATE ( SUM ( 'Input Table'[Amt] ), 'Input Table'[QTR] = "Q1" ),
        "Q2", CALCULATE ( SUM ( 'Input Table'[Amt] ), 'Input Table'[QTR] = "Q2" ),
        "Q3", CALCULATE ( SUM ( 'Input Table'[Amt] ), 'Input Table'[QTR] = "Q3" ),
        "Q4", CALCULATE ( SUM ( 'Input Table'[Amt] ), 'Input Table'[QTR] = "Q4" )
    )
VAR newtab =
    SUMMARIZE (
        tab,
        'Input Table'[ID],
        'Input Table'[Name],
        [Q1],
        [Q2],
        [Q3],
        [Q4],
        "Total",
        VAR _rows = { [Q1], [Q2], [Q3], [Q4] }
        VAR _sum =
            SUMX ( FILTER ( _rows, [Value] <> BLANK () ), [Value] )
        RETURN
            _sum
    )
RETURN
    newtab

The table will like this:

table.png

You can put these fields in the table visual:

table re.png

 

Attached my sample file that hopes to help you, please check and try it: Show quarter in column.pbix

 

Best Regards,
Yingjie Li

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

amitchandak
Super User
Super User

@Anonymous , As Hybrid table is not supported, you have tried a solution suggested by @Greg_Deckler . I have logged and idea for that, Vote for that. Or As of now, the way out is a column for each qtr.

https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/39773011-hybrid-table

 

Hybrid.png

 

 

Greg_Deckler
Super User
Super User

@Anonymous - Why can't you use a Matrix visualization? That seems to be the right choice for what you are going for. You might find this useful: https://community.powerbi.com/t5/Quick-Measures-Gallery/The-New-Hotness-Custom-Matrix-Hierarchy/td-p/963588


@ 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...

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.