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
Sarah-Barlow
Frequent Visitor

Create table from another table with conditions

I have data that gets updated monthly, but not all the names in the rows are updated each month so I need to create a new table with three columns (Name, Date, All … so the same name only appears once in the rows) to pull the latest data, ie. If date = 01 January 2023 return value in ALL in new table, else

C305D197-BCBC-454A-8A08-AB37D4DCA9F9.jpeg

if date = 01 December 2022 return ALL value in new table and so on, ie. Babylon last submitted data on 01 April 2021, return name, date and ALL value in new table, Enfield last submitted data on 01 January 2023, return  data in new table … can anyone help with this please?

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Sarah-Barlow 

According to your description, you want to get a table that has the only one [PCN_Name] and the only one max  of [Effective_Snapshot_Date]. And the corresponding [ALL] value.

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1675649004749.png

(2)We can click "New Table" and enter this:

Table 2 = ADDCOLUMNS( SUMMARIZE('Table','Table'[PCN_Name] , "Effective_Snapshot_Date" ,CALCULATE( MAX('Table'[Effective_Snapshot_Date]))) , "ALL" ,  CALCULATE( SUM('Table'[ALL]),TREATAS({[Effective_Snapshot_Date]},'Table'[Effective_Snapshot_Date]),TREATAS({[PCN_Name]},'Table'[PCN_Name])))

(3)Then we can meet your need , the result is as follows:

vyueyunzhmsft_1-1675649212286.png

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

6 REPLIES 6
v-yueyunzh-msft
Community Support
Community Support

Hi , @Sarah-Barlow 

According to your description, you want to get a table that has the only one [PCN_Name] and the only one max  of [Effective_Snapshot_Date]. And the corresponding [ALL] value.

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1675649004749.png

(2)We can click "New Table" and enter this:

Table 2 = ADDCOLUMNS( SUMMARIZE('Table','Table'[PCN_Name] , "Effective_Snapshot_Date" ,CALCULATE( MAX('Table'[Effective_Snapshot_Date]))) , "ALL" ,  CALCULATE( SUM('Table'[ALL]),TREATAS({[Effective_Snapshot_Date]},'Table'[Effective_Snapshot_Date]),TREATAS({[PCN_Name]},'Table'[PCN_Name])))

(3)Then we can meet your need , the result is as follows:

vyueyunzhmsft_1-1675649212286.png

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

 

Thank you!

Syndicate_Admin
Administrator
Administrator

Hi, I'm new to the forum but I'll try to help you.
I don't know if I understand your query correctly.
You have that table that you show and what you want is to create another one from that if for example the date is > 01/01/2023?

You can do that with the CALCULATETABLE(nombre_tabla, nombre_tabla(date) function > 01/01/2023 )

I hope it serves you, greetings!

Hi, thank you for your reply.  What I want is all PCN Names who updated their 'ALL' List in Jan 2023 combined with the PCN Names who last updated in say, December 2022 or November 2022, but not in January 2023 … hope that makes sense? Basically, I want to see the last update value 

So it would be something like that?
A table containing the PCN names ONLY from the last update?
If NCPs do not repeat (i.e. a PCN name always refers to the same), I would do the following.
SUMMARIZE(nombre_tabla,
PCN_name,
"PCN_ultimo", MAX(date)
)
See if such a solution works for you.

What I need is a table that would look something like this (No repeated PCN Names, just the last update received):

6418B449-3673-4FF6-A469-6F8480A320DA.jpeg

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.