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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Whisper
Frequent Visitor

Create a new table with an overview route and calculation number of days

Dear power bi users,

I want to do this for the entire green table as follows,
the orange and blue background are an example. The result should be a new table like the red box.


An admission is the column "opnameid_anonym" which can consist of various changes -> column "Afdeling or Omschr".
Between each mutation I want to calculate the number of days -> column "MUT_Date".


Who can help me to create this in Dax or Power Query. (I can also provide you the dataset).
Thank you!

 

image.png

4 REPLIES 4
Anonymous
Not applicable

Hi @Whisper ,

Can you tell me how these values are calculated? DAX can do a lot of calculations, but I need to know the steps before I can convert them to code. Based on your description, you said to count the number of days, Does one row of records represent one day or is there a column dedicated to days that sums the values in the days column? In the former case you can use COUNTROWS for the calculation, in the latter case you can choose SUM.

vjunyantmsft_0-1700887073641.png

Can you provide me with sample data? Don't need all the data, just some for testing.

Best Regards,
Dino Tao



Hi Dino,

 

Thank you for helping me with this case 👍
The "Mut_datum" column contains the start date. I make a difference of 2 dates as in the example.

 

Whisper_0-1700909283049.png

A sample of data can you find here -> https://www.frankmartens.be/data.zip 

 

Thank you very much!
Frank

Anonymous
Not applicable

Hi @Whisper ,

I'm sorry, but I can't open the link you provided to the sample data, and I can only test it using this screenshot you provided.
I will you in the screenshot of the four data calculated using the DAX function, but according to your requirements if you want to use a DAX will be the entire table of data are calculated is not possible, you can only one by one calculation.

Days_mut 1_A = 
VAR Event1_start =
CALCULATE(
    MIN('Table1'[MUT_DATUM]),
    FILTER('Table1', 'Table1'[OMSCHR]="Libra 3")
)
VAR Event2_start =
CALCULATE(
    MIN('Table1'[MUT_DATUM]),
    FILTER('Table1', 'Table1'[OMSCHR]="De Zeilen 2")
)
RETURN
DATEDIFF(Event1_start, Event2_start,DAY)
Days_mut 2_A = 
VAR Event2_start =
CALCULATE(
    MIN('Table1'[MUT_DATUM]),
    FILTER('Table1', 'Table1'[OMSCHR]="De Zeilen 2")
)
VAR Event2_end =
CALCULATE(
    MAX('Table1'[MUT_DATUM]),
    FILTER('Table1', 'Table1'[OMSCHR]="De Zeilen 2")
)
RETURN
DATEDIFF(Event2_start, Event2_end,DAY)
Days_mut 1_B = 
VAR Event1_start =
CALCULATE(
    MIN('Table2'[MUT_DATUM]),
    FILTER('Table2', 'Table2'[OMSCHR]="Libra 1")
)
VAR Event2_start =
CALCULATE(
    MIN('Table2'[MUT_DATUM]),
    FILTER('Table2', 'Table2'[OMSCHR]="Vega")
)
RETURN
DATEDIFF(Event1_start, Event2_start,DAY)
Days_mut 2_B = 
VAR Event2_start =
CALCULATE(
    MIN('Table2'[MUT_DATUM]),
    FILTER('Table2', 'Table2'[OMSCHR]="Vega")
)
VAR Event1_end =
CALCULATE(
    MAX('Table2'[MUT_DATUM]),
    FILTER('Table2', 'Table2'[OMSCHR]="Libra 1")
)
RETURN
DATEDIFF(Event2_start, Event1_end,DAY)

The final results are as follows:

vjunyantmsft_0-1701057045110.png

You can put these metrics into visual objects to create the visual effects you need.

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Dino,

 

Strange you can't open the dataset. Have you looked in your Downloads? 

I understand your Dax calculation, thank you for it. Maybe I didn't describe it clearly.
There is 1 Fact table ("Fact_Mutaties") like the table below.
I want a new table where for each "opnameid_anonym"  when (OMSCHR) changes the number of days are calculated like in the example where I did the first 5 "Opnameid_anonym".

When there is no end date then leave it blank. 

Many thanks in advance!
New table

Whisper_1-1701078894273.png

Fact table ("Fact_Mutaties")

MUT_DATUMMutatie_Uuropnameid_anonymAFDELINGOMSCHR
23/02/202320:50:000004AE5A-7D2C-48CD-92C9-081CCB276B1A7Libra 3
29/03/202310:50:000004AE5A-7D2C-48CD-92C9-081CCB276B1A7Libra 3
4/04/202317:00:000004AE5A-7D2C-48CD-92C9-081CCB276B1A7Libra 3
6/04/20239:34:000004AE5A-7D2C-48CD-92C9-081CCB276B1A20De Zeilen 2
27/04/202317:59:000004AE5A-7D2C-48CD-92C9-081CCB276B1A20De Zeilen 2
30/04/20239:58:000004AE5A-7D2C-48CD-92C9-081CCB276B1A20De Zeilen 2
30/04/20239:59:000004AE5A-7D2C-48CD-92C9-081CCB276B1A20De Zeilen 2
23/05/202323:00:000004AE5A-7D2C-48CD-92C9-081CCB276B1A20De Zeilen 2
17/04/20239:55:000008106E-BDF2-4831-8D59-6CA1FC4D62F45Libra 1
17/04/202310:30:000008106E-BDF2-4831-8D59-6CA1FC4D62F45Libra 1
24/04/20238:40:000008106E-BDF2-4831-8D59-6CA1FC4D62F45Libra 1
29/06/20238:30:0000132D5E-0151-469C-A79D-4BF7A4203C96151Nova 2
29/09/20238:30:0000132D5E-0151-469C-A79D-4BF7A4203C96151Nova 2
2/03/202310:45:000023D137-4C61-4FC4-9896-E6D43BACE19A13Sirius 2
7/08/202219:10:0000432BCD-BE6E-4E05-9B54-4B8D05C2B3627Libra 3
9/08/202216:00:0000432BCD-BE6E-4E05-9B54-4B8D05C2B3627Libra 3
11/08/20229:59:0000432BCD-BE6E-4E05-9B54-4B8D05C2B3629Orion 2
24/11/202210:00:000046A647-4184-4374-8583-38F35721CB6314Sirius 3
26/11/202211:00:000046A647-4184-4374-8583-38F35721CB6314Sirius 3
31/01/202310:05:0000507898-44A0-48AD-8529-F32C0902B6685Libra 1
31/01/202310:23:0000507898-44A0-48AD-8529-F32C0902B6685Libra 1
31/01/202312:15:0000507898-44A0-48AD-8529-F32C0902B6685Libra 1
14/02/202311:25:0000507898-44A0-48AD-8529-F32C0902B6685Libra 1
9/03/20228:30:000054BA9A-8AC2-4FEA-B093-113350BD125C151Nova 2
10/06/20228:30:000054BA9A-8AC2-4FEA-B093-113350BD125C151Nova 2
14/11/20228:30:000054BA9A-8AC2-4FEA-B093-113350BD125C160Vega
18/11/20227:00:000054BA9A-8AC2-4FEA-B093-113350BD125C160Vega
21/11/20228:30:000054BA9A-8AC2-4FEA-B093-113350BD125C151Nova 2
2/12/202211:30:000054BA9A-8AC2-4FEA-B093-113350BD125C160Vega
8/12/202210:38:000054BA9A-8AC2-4FEA-B093-113350BD125C160Vega
12/12/20228:30:000054BA9A-8AC2-4FEA-B093-113350BD125C151Nova 2
16/11/20229:55:000055D075-1927-4989-A58E-56DEF81808E214Sirius 3
15/12/20228:30:000055D075-1927-4989-A58E-56DEF81808E214Sirius 3
10/02/202318:15:00005A5FF0-BD6B-4C44-92E5-C906AA74A3C79Orion 2
11/02/202313:00:00005A5FF0-BD6B-4C44-92E5-C906AA74A3C79Orion 2
3/04/202315:00:00006165D7-BB8F-4073-9E05-20B3E3F991A65Libra 1
12/04/202317:00:00006165D7-BB8F-4073-9E05-20B3E3F991A65Libra 1
14/04/202312:25:00006165D7-BB8F-4073-9E05-20B3E3F991A65Libra 1
1/09/20229:55:00006A81B4-EB9D-4595-B27B-E1DFC2071C1D5Libra 1
5/09/20228:00:00006A81B4-EB9D-4595-B27B-E1DFC2071C1D5Libra 1
3/10/202215:50:00006A81B4-EB9D-4595-B27B-E1DFC2071C1D6Libra 2
16/08/202210:00:000071E31E-3D2A-4D0B-946C-4C0C2233FFA116Spika 1
7/07/202314:20:0000838DA3-F96D-488D-9FC1-1BBF153569B4160Vega
24/02/202315:55:000089E521-F0F0-46F6-BA69-874A106DCE6219De Zeilen 1
1/03/202223:30:000090659F-A3CC-42AA-B818-657F6CB65C7C160Vega
3/02/202212:25:0000913D1D-4EF3-4002-8D54-2CC0CC2A8CF55Libra 1
1/03/202210:30:0000913D1D-4EF3-4002-8D54-2CC0CC2A8CF55Libra 1
5/06/202310:05:00009343A4-1279-4483-A4EE-4942088306A77Libra 3
6/06/20238:28:00009343A4-1279-4483-A4EE-4942088306A77Libra 3
26/06/202310:34:00009343A4-1279-4483-A4EE-4942088306A77Libra 3
27/06/202310:50:00009343A4-1279-4483-A4EE-4942088306A76Libra 2
4/02/20229:35:000094518F-A96F-4286-8DC0-9993E65D6A815Libra 1
5/02/202210:00:000094518F-A96F-4286-8DC0-9993E65D6A816Libra 2
28/01/20228:00:00009933B3-5DEB-44A3-9C8E-6FD7E8252B4D162Mira
28/03/20229:15:00009933B3-5DEB-44A3-9C8E-6FD7E8252B4D162Mira
30/07/202212:59:00009933B3-5DEB-44A3-9C8E-6FD7E8252B4D162Mira
3/10/20227:00:00009933B3-5DEB-44A3-9C8E-6FD7E8252B4D162Mira
18/09/202314:40:0000A0B131-D3EA-4FD9-8F58-4B5CDD4BC7D27Libra 3
21/09/20237:51:0000A0B131-D3EA-4FD9-8F58-4B5CDD4BC7D27Libra 3
14/01/20229:30:0000A32A4A-5F94-4B87-A435-FE8E945524B35Libra 1
17/01/202210:27:0000A32A4A-5F94-4B87-A435-FE8E945524B3160Vega
28/01/202213:40:0000A32A4A-5F94-4B87-A435-FE8E945524B35Libra 1
14/02/202215:50:0000A32A4A-5F94-4B87-A435-FE8E945524B35Libra 1
23/02/202211:05:0000A32A4A-5F94-4B87-A435-FE8E945524B35Libra 1
7/03/202216:15:0000A32A4A-5F94-4B87-A435-FE8E945524B35Libra 1
20/05/202215:15:0000A32A4A-5F94-4B87-A435-FE8E945524B35Libra 1
11/03/202215:20:0000AD2094-51F1-4FA2-BA3C-88B2CB7676FD20De Zeilen 2
15/03/202217:09:0000AD2094-51F1-4FA2-BA3C-88B2CB7676FD20De Zeilen 2
11/09/202315:40:0000C12581-2D1B-4BB6-9E33-A94A6D0BA1D713Sirius 2
20/05/202220:35:0000C60BEE-CCBC-497C-A308-FB69C7D870039Orion 2
16/01/202217:00:0000EF73CC-6981-499B-8114-118728FBF8E17Libra 3
19/01/20229:00:0000EF73CC-6981-499B-8114-118728FBF8E17Libra 3
9/08/202310:40:0000EFAB2E-FF01-42C4-821C-FB08D5A8A559150Nova 1
16/08/202314:25:0000EFAB2E-FF01-42C4-821C-FB08D5A8A559150Nova 1
30/06/20229:55:0000FDF28C-BFFB-4879-A80B-2DB008FFEDB8150Nova 1
6/07/202210:00:0000FDF28C-BFFB-4879-A80B-2DB008FFEDB8150Nova 1
14/07/20239:30:00010E32D3-7238-465C-AFD5-7E9ECC6EE4887Libra 3
22/02/202223:00:0001392978-247A-4A97-874D-31878C6C883F10Orion 3
24/08/202223:00:0001392978-247A-4A97-874D-31878C6C883F10Orion 3
31/12/20227:00:0001392978-247A-4A97-874D-31878C6C883F10Orion 3
14/01/20238:30:0001392978-247A-4A97-874D-31878C6C883F11Orion 4
16/03/20238:50:00013A64F7-63DD-4AA4-B3E2-7F60486D23D85Libra 1
5/01/202212:53:00016E9B85-8036-4B29-8166-909B6ACF0B9914Sirius 3
27/03/202221:05:00017004E3-D917-4CC3-9F56-33BEA032D90C150 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors