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
Anonymous
Not applicable

Label each sales with different date ranges

Hello

My business define each sales by "date_order" and "date_delivery".

Therefore, I have a Sales_Table.
Sales tableSales table
and a Label_Table
Label_TableLabel_Table

The aim is to label the Sales_Table. Here is the expected result.
result expected.png


I would like to avoid a huge work by creating an index tables (which would concatenate OrderDate and DeliveryDate) from 2018 to 2019 with all the possibilities on excel.

Have you got a dynamic solution please ?

1 ACCEPTED SOLUTION
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous

 

You may refer to below measure and drag it for sales table.

Measure  =
CALCULATE (
    MAX ( Label[Label] ),
    FILTER (
        GENERATE ( Sales, Label ),
        Sales[Order date] >= Label[OrderDate_start]
            && Sales[Order date] <= Label[OrderDate_end]
            && Sales[Delivery date] >= Label[Delivery date_start]
            && Sales[Delivery date] <= Label[Delivery date_end]
    )
)

Regards,

Cherie

Community Support Team _ Cherie Chen
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

5 REPLIES 5
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous

 

You may refer to below measure and drag it for sales table.

Measure  =
CALCULATE (
    MAX ( Label[Label] ),
    FILTER (
        GENERATE ( Sales, Label ),
        Sales[Order date] >= Label[OrderDate_start]
            && Sales[Order date] <= Label[OrderDate_end]
            && Sales[Delivery date] >= Label[Delivery date_start]
            && Sales[Delivery date] <= Label[Delivery date_end]
    )
)

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thanks a lot @v-cherch-msft , your solution is perfect as a measure.
Have you got a similar formula to convert this measure in column ?
I tried to use addcolums without success 😞

Anonymous
Not applicable

I created a table inspired from your formula.

 

TableJoin = SELECTCOLUMNS(
FILTER(
CROSSJOIN(Label;'Order');
[Order date] >= Label[OrderDate _ start].[Date]
&& [Order date] <= Label[OrderDate_end].[Date]
&& [Delivery date] >= Label[DeliveryDate_start].[Date]
&& [Delivery date] <= Label[DeliveryDate_end].[Date]);
"OrderID"; [OrderID];"Label" ; Label[Label] )
Greg_Deckler
Community Champion
Community Champion

Can you post that data in text, I really don't want to type all of that.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler

 

Oh deeply sorry, here is the data

 

Label;OrderDate _ start;OrderDate_end;DeliveryDate_start;DeliveryDate_end
A;43101;43240;43105;43342
B;43241;43311;43282;43444
C;43312;43465;43313;43480
D;43435;43600;43481;43616

 

OrderID;Order Date;Delivery Date
1;43133;43250
2;43194;43251
3;43240;43342
4;43240;43344
5;43241;43282
6;43241;43245
7;43311;43444
8;43312;43444
9;43444;43474
10;43465;43480
11;43435;43481
12;43465;43481
13;43599;43616
14;43599;43617
15;43601;43603

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.