Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
KoppulaPSR
Frequent Visitor

How do I populate my result column names dynamically in DAX Query?

Dear experts,

 

I have requirment to populate column names dynamically using DAX query. 

 

Use case:-

 

Using below DAX Query i am fetching Product Color wise sales for selected day as well as for previous day, presently i have managed those measure names as "SelectedDaySales" , "PreviousDaySales". However, my requirment is instea of Selected & Previous daysales, need to replace with dates as measure names. It will be like below mentioned screenshot. Is it possible? Normally in MDX we can use "MemberValue" property and achive the requirment. Not sure is there any way we can do in DAX.

Please advise.

 

 

EVALUATE
VAR _ProductCat = distinct ('Product'[Color])
VAR _Time= SELECTCOLUMNS(FILTER('Date','Date'[Date]= DATE(2013,07,02)),"Day",'Date'[Date])
VAR _ColorWiseSales = ADDCOLUMNS(
CROSSJOIN(_ProductCat,_Time),
									"SelectedDaySales",'Internet Sales'[Drvd_Internet_Total_Sales],
									"PreviousDaySales",CALCULATE('Internet Sales'[Drvd_Internet_Total_Sales],
									PREVIOUSDAY('Date'[Date])))

VAR Result = FILTER(_ColorWiseSales,
							not isblank('Internet Sales'[Drvd_Internet_Total_Sales]) && 'Product'[Color]<>"NA")
RETURN Result

 
 

 

 

DAX_Query.png

 

 

4 REPLIES 4
Anonymous
Not applicable

Hi @KoppulaPSR ,

You can follow the steps below to get it in Power BI:

1. Create a measure below 

 

Measure =
VAR _color =
    SELECTEDVALUE ( 'Product'[Color] )
VAR _date =
    DATE ( 2013, 07, 02 )
VAR _seldate =
    SELECTEDVALUE ( 'Date'[Date] )
VAR _pids =
    CALCULATETABLE (
        VALUES ( 'Product'[productid] ),
        FILTER ( 'Product', 'Product'[Color] = _color && 'Product'[Color]<>"NA" )
    )
VAR  sales =
    SUMX (
        FILTER (
            ALLSELECTED ( 'Internet Sales' ),
            'Internet Sales'[Date] = _seldate 
                && 'Internet Sales'[productid] IN _pids
        ),
        [Drvd_Internet_Total_Sales]
    )
RETURN
    IF ( _seldate IN { _date - 1, _date }, sales , BLANK () )

 

2. Create a matrix visual( Rows: 'Product'[Color]  Columns: 'Date'[Date]  Values: [Measure])

vyiruanmsft_1-1720071812839.png

Best Regards

@Anonymous 

Thank you for the idea, in my case need to handle the use case in Tabular Cube under "Detailed Row expression".

Any inputs would be highly appreciated.

 

 

Anonymous
Not applicable

Hi @KoppulaPSR ,

Do you mean the one in below screenshot? In that case, I'm afraid I can't fulfill your needs...

use case in Tabular Cube under "Detailed Row expression".


vyiruanmsft_0-1720167505746.png

Best Regards

Exactly need to handle in Tabular Cube, the problem is now we are migrating from Multi-Dimensional Cube to Tabular Cube and planning to host Tabular Cube in Azure Cloud under PaaS model.
Since the use case already working in MOLAP Cube, client is expecting as it is in Tabular Cube. Not sure whether MS planning to implement this kind of functionality in future.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.