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 September 15. Request your voucher.

Reply
awitt1Temp
Frequent Visitor

Measure returning column text value based on date

I have a data set of sales, items and product grouping that I have previously been able to group in this way. I have custom column written that returns a value of Core or Closeout based on when the item was ordered. So if an item was ordered on or before March 1, then it should be grouped according to the CoreGroup column and if it is after, then it should be grouped according to the CoreGroup2 column. 

RelatedCoreGroup = 
VAR SalesLineCreated = SalesTable[Sales Line Created Date] -- This is your date column in the Sales table
VAR RelatedBeforeDate = RELATED('Product Grouping'[CoreGroup]) -- Get related value from the first relationship
VAR RelatedAfterDate = RELATED('Product Grouping'[CoreGroup2]) -- Get related value from the second relationship
VAR Result = 
    IF (
        SalesLineCreated <= DATE(2025, 3, 1), -- Check if the date is on or before March 31, 2023
        RelatedBeforeDate, 
        RelatedAfterDate
    )
RETURN
    IF (
        ISBLANK(Result),
        "Other", -- If the result is blank, return 'Other'
        Result
    )

 

awitt1Temp_0-1743430637673.png

 

My issue now is that I am forced to Direct Query this data instead of importing so I cannot create a custom column but I still need the same functionality. Any thoughts as to how to achieve this in measures and not in custom columns? I've looked into parameters and other things but cannot get over the finish line with it. PBIX below.



Fake Data PBIX File 

5 REPLIES 5
v-nmadadi-msft
Community Support
Community Support

Hi @bzeeblitz 
Could you please confirm if your issue has been resolved If so, sharing the details here would be helpful for other community members who may have similar feedback.

If we don’t hear back, we’ll go ahead and close this thread. For any further discussions or questions, please start a new thread in the Microsoft Fabric Community Forum  we’ll be happy to assist.

Thank you

v-nmadadi-msft
Community Support
Community Support

Hi @awitt1Temp,

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the community members for the issue worked. If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

 

Thanks and regards

v-nmadadi-msft
Community Support
Community Support

Hi @awitt1Temp,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If our responses has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.


Thank you.

v-nmadadi-msft
Community Support
Community Support

Hi @awitt1Temp,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

DataNinja777
Super User
Super User

Hi @awitt1Temp ,

 

Since you are now using DirectQuery, you cannot create calculated columns like your previous RelatedCoreGroup, but you can achieve the same result using a DAX measure. The idea is to use a measure that dynamically determines whether to show "Core" or "Closeout" based on the Sales Line Created Date. Here's the DAX measure that replicates your original logic:

RelatedCoreGroupMeasure =
VAR SalesLineCreated = MAX(SalesTable[Sales Line Created Date])
VAR RelatedBeforeDate = MAX('Product Grouping'[CoreGroup])
VAR RelatedAfterDate = MAX('Product Grouping'[CoreGroup2])
VAR Result =
    IF (
        SalesLineCreated <= DATE(2025, 3, 1),
        RelatedBeforeDate,
        RelatedAfterDate
    )
RETURN
    IF (
        ISBLANK(Result),
        "Other",
        Result
    )

You can use this measure in your visual to reflect the correct group label based on the date. However, since measures cannot be used as row groupings in matrix visuals, this approach works best if you only need to display the group label or use it in tooltips or conditional logic. If you need to use the result for grouping rows, you'll have to consider alternatives such as creating a disconnected group table or pre-aggregated calculated table, though those are more limited in DirectQuery mode. Let me know if you need help adapting the visual to support grouping with this logic.

 

Best regards,

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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