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

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
Employee
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
Employee
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
Super User
Super User

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


@ 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!:
The Definitive Guide to Power Query (M)

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
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.