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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Differrance betwee two values in rows

Hi,

I got the follwing issue.

 

in a table i got a number of maximum times allowed.

In a other table i got the times given.

 

Now i want to see all rows where the given times are greater than the allowed times.

So for example, the lower line is teh one i want to see as "check" because the values "max omvang...." is smaller than the "aantal afgegeven"

 

Knipsel.JPG

1 ACCEPTED SOLUTION

Hello @Anonymous 

 

the solution I proposed is Power Query. That what you are stating is DAX. 

If the DAX solution is okay, go for it. 

However, if you are copying my code into the advanced editor, it should not spin. Is a straightforward code. This is the result of combining the example data in my code

image.png

 

Jimmy

View solution in original post

16 REPLIES 16
AnkitBI
Solution Sage
Solution Sage

Hi @Anonymous 

 

Are both Columns for Maximum Times allowed and Times given in same table or different tables?

 

Thanks

Ankit Jain

Anonymous
Not applicable

They are both in different tables

Hi @Anonymous  Can you share sample data from both table in that case.

Anonymous
Not applicable

Not sure how,

There is a table called "Codering max trances" with two collums "Productcode" and "max omvang"

This got a relation with a table called "DimVoorziening" on productcode.

The table "DimVoorziening"has a relation with a table called "FeitNVTZ" on a unique codenumber, different from the productcode.

Finaly there is a relation from "FeitNVTZ"to a table called "FeitLevering"

This last table contains the values of the the given form collum "aVolume"

 

So what i need is the difference between

"Codering max trances"[max omvang] - "FeitLevering"[aVolume]

Then, when the value is 0 or less than zero i want to filter on those values so someone can get in contact with the company's which has more trances than the max volume.

dax
Community Support
Community Support

Hi H_Delwel,

If possible, could you please inform me more detailed information (such  as your sample data an your expected output)? Then I will help you more correctly.

 

Please do mask sensitive data before uploading.

Thanks for your understanding and support.
Best Regards,
Zoe Zhi

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

Anonymous
Not applicable

Can you do somthing with this?

The last collum(H)  is what i'm trying to make from the two different tables (FeitLevering and CoderingMaxTrances)

So value maxOmvang minus aVolume

 

 

Knipsel.PNG

dax
Community Support
Community Support

Hi H_Delwel,

Yes, I will try to get the result of your image, but if possible, could you please show me the four table samples instead of showing the data in same visual, I need to know their structure and try to reproduce this in my environment.

 

Please do mask sensitive data before uploading.

Thanks for your understanding and support.
Best Regards,
Zoe Zhi

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

Anonymous
Not applicable

Hi Zoe,

Do you mean like this?

codering max trances.JPG

hello @Anonymous 

 

I think there are some misunderstandings. Tried to figure out a solution for you. Please check if the concept of this codes works for you.

let
	TableA = #table
	(
		{"Object","Max Allowed"},
		{
			{"A","15"},	{"B","10"},	{"C","10"},	{"D","5"}
		}
	),
    ChangedTypeA = Table.TransformColumnTypes(TableA,{{"Max Allowed", Int64.Type}}),
    TableB = #table
	(
		{"Object","Times"},
		{
			{"A","1"},	{"B","1"},	{"C","1"},	{"D","1"},	{"A","1"},	{"B","1"},	{"C","1"},	{"D","1"},	{"A","1"},	{"B","1"},	{"C","1"},	{"D","1"},	{"A","1"},	{"B","1"},	
			{"C","1"},	{"D","1"},	{"A","2"},	{"B","3"},	{"C","4"},	{"D","5"},	{"A","6"},	{"A","7"},	{"A","8"},	{"B","9"},	{"B","10"},	{"D","11"},	{"D","12"},	{"D","13"},	
			{"D","14"}
		}
	),
    ChangedTypeB = Table.TransformColumnTypes(TableB,{{"Times", Int64.Type}}),
    JoinTables = Table.NestedJoin
    (
        ChangedTypeA,
        "Object",
        ChangedTypeB,
        "Object",
        "Times"
    ),
    CountRowTimes = Table.AggregateTableColumn(JoinTables, "Times", {{"Times", List.Count, "Count of Times"}}),
    AddCheck = Table.AddColumn(CountRowTimes, "Check", each if [Count of Times]>[Max Allowed] then "check" else "not check")

in
	AddCheck

Copy paste this code to the advanced editor to see how the solution works. If this solution fits your need, copy and past a part of it and implement it in your query.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Anonymous
Not applicable

Hi Jimmy,

I'm getting an error on this "EOF" missing.

 

 

Hello @Anonymous 

 

copy the data into the advanced editor. You don't have appended any screenshot, but I suppose you have copied into the formula bar

 

Jimmy

Anonymous
Not applicable

Hi Jimmy,

I'd copied it in the avanced editor.

 

I got another solution where they say:

Difference = (COUNTA('Codering max trances' [Max omvang standaard eenheid ZIN]) - COUNTA('FeitLevering'[aVolume])

 

This looks like a simple solution, However for some reason there is no result. (The wheel keeps spinning)

Hello @Anonymous 

 

the solution I proposed is Power Query. That what you are stating is DAX. 

If the DAX solution is okay, go for it. 

However, if you are copying my code into the advanced editor, it should not spin. Is a straightforward code. This is the result of combining the example data in my code

image.png

 

Jimmy

Anonymous
Not applicable

@Jimmy801 

Yes its work now 🙂

 

I'd tried it in a current table, now i just made a new query 🙂

 

Thanx a lot

Hi @Anonymous 

You can share sample data from 4 tables based on one Productcode. Won't be able to help without the sample data. Someone else might be able to help.

 

Thanks

Ankit Jain

 

Hi @Anonymous 

If in Same table, then use below.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8i8tccovzUtR0lGK8vQDkobGECJWh36S+OTMCBlqphQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ColA = _t, ColB = _t, TimesAllowed = _t, MaxTimesAllowed = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ColA", type text}, {"ColB", type text}, {"TimesAllowed", Int64.Type}, {"MaxTimesAllowed", Int64.Type}}),
    IsTimesAllowedGreater = Table.AddColumn(#"Changed Type","IsGreater",each if ([TimesAllowed] > [MaxTimesAllowed]) then "Y" else "N",type text),
    #"Filtered Rows" = Table.SelectRows(IsTimesAllowedGreater, each ([IsGreater] = "Y"))
in
    #"Filtered Rows"

 

Thanks
Ankit Jain
Do Mark it as solution if the response resolved your problem. Do Kudo the response if it seems good and helpful.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors