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

[DAX] how to change row context to column in relation to a date

Hi,

 

I found already half solution of my problem in this post (https://community.powerbi.com/t5/Desktop/DAX-how-to-change-row-context-to-column/m-p/42610#M16308).

But I need to have the results by a specific date.

Here is a example of how the data looks like and how I want to have it.

 

Device CategoryDateAvg. Order ValueConversionTransactionSessionsSales Line
desktop01.01.201611,560,2612514589MMDE
desktop02.01.201611,560,2612514589MMDE
desktop03.01.201611,560,2612514589MMBE
desktop04.01.201611,560,2612514589MMBE
desktop05.01.201611,560,2612514589MMSE
desktop06.01.201611,560,2612514589MMSE
desktop07.01.201611,560,2612514589MMGR
desktop08.01.201611,560,2612514589MMGR
desktop09.01.201611,560,2612514589MMDE
desktop10.01.201611,560,2612514589MMBE
desktop11.01.201611,560,2612514589MMSE
       
       
DateMMDEMMBEMMSEMMGR  
01.01.20160,26000  
02.01.20160,26000  
03.01.201600,2600  
04.01.201600,2600  
05.01.2016000,260  
06.01.2016000,260  
07.01.20160000,26  
08.01.20160000,26  

 

 

When I use the DAX expression from the post I get the same amount of each date.

 

Calculated Column:

 

MMDE = CALCULATE(AVERAGEX(ALL_DATA_ALL;ALL_DATA_ALL[Ecommerce Conversion Rate]);ALL_DATA_ALL[Sales Line]="MMDE")

 

Thanks you in advance.

 

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

@Anonymous

1) It seems you want to create a New Table right? (using SUMMARIZE)

 

2) And you are entering your MMDE formula as a column in this new Summary table?

however those 2 tables are probably NOT related and that's why you are getting this answer!

 

3) You should be incorporating your MMDE formula as part of the SUMMARIZE statement when creating the table

OR

set up a relationship between the 2 tables.

 

Summary Table =
SUMMARIZE (
    ALL_DATA_ALL,
    ALL_DATA_ALL[Date],
    "MMDE", CALCULATE (
        AVERAGE ( ALL_DATA_ALL[Conversion] ),
        ALL_DATA_ALL[Sales Line] = "MMDE"
    ),
    "MMBE", CALCULATE (
        AVERAGE ( ALL_DATA_ALL[Conversion] ),
        ALL_DATA_ALL[Sales Line] = "MMBE"
    ),
    "MMSE", CALCULATE (
        AVERAGE ( ALL_DATA_ALL[Conversion] ),
        ALL_DATA_ALL[Sales Line] = "MMSE"
    ),
    "MMGR", CALCULATE (
        AVERAGE ( ALL_DATA_ALL[Conversion] ),
        ALL_DATA_ALL[Sales Line] = "MMGR"
    )
)

Resulting in...

Summary Table - Averages.png

 

Or if you have a relationship between the tables...

 

MMDE Column =
CALCULATE (
    AVERAGEA ( ALL_DATA_ALL[Conversion] ),
    ALL_DATA_ALL[Sales Line] = "MMDE"
)

Summary Table - Averages2.png

 

Hope this helps! Smiley Happy

View solution in original post

2 REPLIES 2
Sean
Community Champion
Community Champion

@Anonymous

1) It seems you want to create a New Table right? (using SUMMARIZE)

 

2) And you are entering your MMDE formula as a column in this new Summary table?

however those 2 tables are probably NOT related and that's why you are getting this answer!

 

3) You should be incorporating your MMDE formula as part of the SUMMARIZE statement when creating the table

OR

set up a relationship between the 2 tables.

 

Summary Table =
SUMMARIZE (
    ALL_DATA_ALL,
    ALL_DATA_ALL[Date],
    "MMDE", CALCULATE (
        AVERAGE ( ALL_DATA_ALL[Conversion] ),
        ALL_DATA_ALL[Sales Line] = "MMDE"
    ),
    "MMBE", CALCULATE (
        AVERAGE ( ALL_DATA_ALL[Conversion] ),
        ALL_DATA_ALL[Sales Line] = "MMBE"
    ),
    "MMSE", CALCULATE (
        AVERAGE ( ALL_DATA_ALL[Conversion] ),
        ALL_DATA_ALL[Sales Line] = "MMSE"
    ),
    "MMGR", CALCULATE (
        AVERAGE ( ALL_DATA_ALL[Conversion] ),
        ALL_DATA_ALL[Sales Line] = "MMGR"
    )
)

Resulting in...

Summary Table - Averages.png

 

Or if you have a relationship between the tables...

 

MMDE Column =
CALCULATE (
    AVERAGEA ( ALL_DATA_ALL[Conversion] ),
    ALL_DATA_ALL[Sales Line] = "MMDE"
)

Summary Table - Averages2.png

 

Hope this helps! Smiley Happy

Anonymous
Not applicable

Thanks for your help. It works just perfect.

 

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.