Forum Discussion

SanchoPL's avatar
SanchoPL
New Member
1 year ago
Solved

Rows headers into columns on the visualisation

Hi,

I have an issue which I try to solve and i am wondering if its possible.

 

I have a table with data (consumption) which collect data for various meters, each specific meter is a single column.

data are present stored in the calender. 

Therefore a value has two tags first time frame in the row and name of the meter in the column.

 

what i want to do is to list in the rows collumn headers and display data by month in specific column.

I dont want to change the data in the power query but only do it while displaying, is it possible?

 

Table:

DataMeter 1Meter 2Meter 3Meter 4Meter 5Meter 6Meter 7
01.01.202361381810821931021003752338884264742647
01.02.20235730301076662687104983,32477773794837948
01.03.2023609108832223344114977,82116664526945269
01.04.202353865147172284285972,221296674244742447
01.05.202359610196214242215777,78191664396343963
01.06.202370667112727026957027,7891674609046090
01.07.202388303418124231806472,22100004910849108
01.08.202397529919570230974472,22102785004050040
01.09.202384722516790026851861,11102774513245132
01.10.20236839808190437638972,2157694700347003
01.11.202359757382716443948720,861296574202542025
01.12.2023739643100324517276977,844843274541445414

 

And expected result:

dates to be chosen in slicer

Data    01.01.202301.02.2023
Meter 1613818573030
Meter 2108219107666
Meter 331022687
Meter 4100375104983,33
Meter 5233888247777
Meter 64264737948
Meter 74264737948

 

Many thanks for hints if its possible.

Thanks

SanchoPL

  • Hello SanchoPL,

     

    Can you please try this DAX approach to transform the data dynamically:

    MeterConsumptionTable = 
    VAR UnpivotedTable = 
        UNION(
            SELECTCOLUMNS( 'DataTable', "Meter", "Meter 1", "Date", 'DataTable'[Data], "Consumption", 'DataTable'[Meter 1] ),
            SELECTCOLUMNS( 'DataTable', "Meter", "Meter 2", "Date", 'DataTable'[Data], "Consumption", 'DataTable'[Meter 2] ),
            SELECTCOLUMNS( 'DataTable', "Meter", "Meter 3", "Date", 'DataTable'[Data], "Consumption", 'DataTable'[Meter 3] ),
            SELECTCOLUMNS( 'DataTable', "Meter", "Meter 4", "Date", 'DataTable'[Data], "Consumption", 'DataTable'[Meter 4] ),
            SELECTCOLUMNS( 'DataTable', "Meter", "Meter 5", "Date", 'DataTable'[Data], "Consumption", 'DataTable'[Meter 5] ),
            SELECTCOLUMNS( 'DataTable', "Meter", "Meter 6", "Date", 'DataTable'[Data], "Consumption", 'DataTable'[Meter 6] ),
            SELECTCOLUMNS( 'DataTable', "Meter", "Meter 7", "Date", 'DataTable'[Data], "Consumption", 'DataTable'[Meter 7] )
        )
    
    RETURN UnpivotedTable
    

4 Replies

  • Hello SanchoPL,

     

    Can you please try this DAX approach to transform the data dynamically:

    MeterConsumptionTable = 
    VAR UnpivotedTable = 
        UNION(
            SELECTCOLUMNS( 'DataTable', "Meter", "Meter 1", "Date", 'DataTable'[Data], "Consumption", 'DataTable'[Meter 1] ),
            SELECTCOLUMNS( 'DataTable', "Meter", "Meter 2", "Date", 'DataTable'[Data], "Consumption", 'DataTable'[Meter 2] ),
            SELECTCOLUMNS( 'DataTable', "Meter", "Meter 3", "Date", 'DataTable'[Data], "Consumption", 'DataTable'[Meter 3] ),
            SELECTCOLUMNS( 'DataTable', "Meter", "Meter 4", "Date", 'DataTable'[Data], "Consumption", 'DataTable'[Meter 4] ),
            SELECTCOLUMNS( 'DataTable', "Meter", "Meter 5", "Date", 'DataTable'[Data], "Consumption", 'DataTable'[Meter 5] ),
            SELECTCOLUMNS( 'DataTable', "Meter", "Meter 6", "Date", 'DataTable'[Data], "Consumption", 'DataTable'[Meter 6] ),
            SELECTCOLUMNS( 'DataTable', "Meter", "Meter 7", "Date", 'DataTable'[Data], "Consumption", 'DataTable'[Meter 7] )
        )
    
    RETURN UnpivotedTable
    
  • You've made my day! Its working 🙂

    Thanks a lot for quick answer, I woudn't do it myself as I'm new in Power BI environment.

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi SanchoPL ,
      Glad to hear you may have found a solution! If you're sure the issue has been resolved, could you mark this post as resolved? That way, others with similar issues can more easily find a solution and the community can see that the issue has been resolved.
      Thanks, and feel free to reach out if you need further help!